Android:Task And Back Stack
Here is my question:
In my android app, i have HomeActivity. And then HomeActivity can start sequences of activities through 4 different launching point in home screen Launching Point 1) Will launch Activity 11, Activity 12 ...Activity 21 and so on in sequence. Launching Point 2) Will launch Activity 21, Activity 22 in sequence Launching Point 3) similar to 1 Launching Point 4) Launch More Activity Which in turn launch More Activity 1, More Acivity 2 etc. 开发者_开发知识库If user from home start more activity and then again start home activity and then again start more activity, then all the activities are pushed in to the stack and user can see same screen while navigating back. And the app behavior looks bad.
Please suggest how do i setup home activity and other activities so that whenever i return back to it and press back it goes to the home screen of android device.
There are many ways , one way would be to ,
Whenever you are navigating from one activity to another you can use finish() call in Activity to finish particular activity , so that when you press back you don't see them.
Use it like:
Intent intent = new Intent(Activity1.this, Activity2.class);
Activity1.this.startActivity(intent);
Activity1.this.finish();
精彩评论