开发者

Back Button when previous activities have been cleared due to memory management

I have my workflow set up so that after a user gets through several pages, to where they're essentially "logged on", then if they hit the back button, activities will be cleared up until the root login page. So basically, I go from the top activity, skip past 5 activities, and end up back at the root activity. I accomplish this via onActivityResult().

Now, the problem I'm having is, if the user minimizes my App by using the hardware Home button, and runs other apps which consume large amounts of memory, it seems to be reclaiming the memory from my the activities that are in the activity stack. So when my app is re-opened, the top activity is re-opened (onCreate() is called again, animations run from beginning). Then if I hit the back button, even though I have my activities set up to use onActivityResult() to close all activiti开发者_如何学Pythones up to the Login page, onCreate() is called for each Activity before it realizes, and THEN closes. This means from a user stand point, they can see the titles to each activity flash for a brief second as they're opened and closed, instead of immediately being taken to the Login screen again.

Does anyone know of a way to get around onCreate() being called? I've tried putting in a flag that's set, that's checked within each onCreate() method, to immediately call finish() and return, but Android will not allow me to not call the super.onCreate() method. Calling the super.onCreate() method displays the activity opening, which shows the title, even though setContentView() is never called.


you can try organizing your activities in an ActivityGroup. maybe the children activities won't go through the same thing?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜