Reputation: 479
A have ActivityA-->ActivityB-->ActivityC
. If user push HomeButton while he is at ActivityB
, and then he wants to re-open application i want to restart activity ActivityA
. Well thats working calling onStop();
and finish();
in ActivityB
.
But when user goes from ActivityB
to ActivityC
and then wants to return to ActivityB
, ActivityB
has already called finish();
so user will appear at ActivityA
.
So how to make ActivityB
available if returning from ActivityC
and also finish it if user use HomeButton ?
Upvotes: 1
Views: 156
Reputation: 11961
when your going from Activity B to Activity C don't call finish() on Activity B.
I think your doing like this
startActivity(new Intent(Activity_B.this,Activity_C.class));
finish();
Remove finish() when moving from Activity B to Activity C.
Go to this stackoverflow question for more details you ll get it.
Upvotes: 0
Reputation: 95646
Just set
android:clearTaskOnLaunch="true"
on your root activity (the one used by the launcher to start your application) in the manifest. Then, when the user is using your application, as soon as he presses the HOME key, your task will be stripped back to the root (starting) activity.
Upvotes: 4