0

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.

androidexp
  • 61
  • 1
  • 3
  • In additions to the above question, home activity is kind of a dashboard to which the user can return by clicking the home menu item. – androidexp Mar 15 '11 at 08:24

2 Answers2

0

Use it like:

Intent intent = new Intent(Activity1.this, Activity2.class);  
                    Activity1.this.startActivity(intent);
                    Activity1.this.finish();
Sunil Pandey
  • 7,042
  • 7
  • 35
  • 48
  • This will not solve the problem. As if from home user goes to more activities -> then goes to A1 activity, here finish will clean up the back stack and user will not be able to use back to go back to home. I am interested to clear the stack when i am jumping from activity to home activity – androidexp Mar 15 '11 at 08:08
0

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.

sat
  • 40,138
  • 28
  • 93
  • 102
  • This will not solve the problem. As if from home user goes to more activities
    -> then goes to A1 activity, here finish will clean up the back stack and user will not be able to use back to go back to home. I am interested to clear the stack when i am jumping from activity to home activity
    – androidexp Mar 15 '11 at 07:54
  • Check this , Is this what you require ?http://stackoverflow.com/questions/5308088/kill-all-activities-when-home-key-is-pressed-android – sat Mar 15 '11 at 08:43