开发者

Adding an activity to the stack when the application is in the background

Suppose the user is in the activity A of my application.

The user leave the application (with the home button) and at some point, while he is doing something else, I want to change the stack of my application to A B. I do not want the activity B to pop up from nowhere, I just want开发者_Go百科 that when (if) the user returns to my application, he sees the activity B.

It seems that calling startActivity(B) in the activity A from a background thread works, but I’m not sure this will have the desired behaviour on every platform (what I want is that the user does not see the activity B until he returns to my application)


I may not be following this correctly

If all you are after is saving state (which activity was last active) you could use preferences Shared Preferences

You could then just have a MainActivity that does nothing other than decide which activty should be displayed the next time your application starts

Main

Using preferences find the last activity that was active Start first activity dependent last activity ID or whatever logic you choose

Activity A or B starts/resumes etc - Store activity ID in shared preferences for retrieval later

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜