Please help me this question.
Example I have Activity class MyActivity. I start this Activity and call this instance is “Home”. In this activity I have three button.
called : Button1, Button2, Button3.
When I click on one button, it will start another instance of MyActivity.
So, Could I do like this :
I click on Button1 start A1 , click on Button2 start A2, and then Button3 start A3. We will have activity stack like this : home ->A1 ->A2->A3.
On Activity A3(an instance of MyActivity). When I click on Button1 could I move A1 to front instead of create new one ?
I wonder could I do that ?
If A1, A2 and A3 are all instances of
MyActivityyou cannot do this because there is no way to tell Android which instance ofMyActivityyou want to bring to the front.However, if you create 3 new activities (
A1,A2andA3), each of which derive fromMyActivity, then you can do this by setting the flagIntent.FLAG_ACTIVITY_REORDER_TO_FRONTwhen starting these activities.You will need to have all 4 activities (
MyActivity,A1,A2,A3) in the manifest.You will have something like this:
and in
MyActivity, in ‘onClick()when you start an activity (eitherA1,A2orA3`) you do it like this: