My application has the following flow:
Home->screen 1->screen 2->screen 3->screen 4->screen 5>Home->screen 2->Home->Screen 3
My problem is that when I am try
There are 2 ways for solve your problem
1) call finish() after startActivity(intent) in every activity
2) set android:launchMode="singleInstance" in every tag in menifest file
i think 2nd way is best for solving problem but you can also use first way
Add android:noHistory="true"
in your activity manifest file.
This works well for me.
You should using FLAG_ACTIVITY_CLEAR_TASK
and FLAG_ACTIVITY_NEW_TASK
flags.
Intent intent = new Intent(SecondActivity.this, CloseActivity.class);
//Clear all activities and start new task
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
onCreate()
method of CloseActivity
activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
finish(); // Exit
}