开发者

How to keep track of activities in activity stack

I'd like to keep track of all activities in the activit开发者_高级运维y stack. Does anyone know how to do this from code?


Why do you want to keep a track of activity stack... But there is a way to manipulate the stack using intent flags. Example:

Intent intent=new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

This flag will clear all the activites, from the stack, present above MainActivity, and launch MaintActivity. There are other flags to manipulate the stack as well.. Hope this helps


Pretty much what CommonsWare said. Pretty much any reason to do this is wrong. If you think you need to do it, just stop and ask yourself if it's really needed. Messing with the activity stack in any way will just annoy the user and cause problems for you and them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜