开发者

Android - Tell if parent activity has been destroyed

So, I have written an app that has a Main activity (A), and various other sub-activities that all do something, report the work back to main, and finish.

What I am running into is that if the user leaves my app at Screens B or C, when they come back at a later time and dalvik has destroyed my activities for more RAM... the app starts back at B or C, and reads all the initialization stuff from the saved intent, and continues on as if nothing happened. Until they return back to activity A, where we get a force close from unexpected things.

I've twiddled with overriding onStop() and calling finish, but i think this is a bit scorched earth, I'd like to let them leave on that activity and come back. But i'd also like to detect if the 开发者_如何学运维underlying main activity has been destroyed, and then destroy my entire activity stack.

From reading around, I get the idea that onDestroy() is not always called, so it isnt reliable for me to insert some logic into Activity A's onDestroy.... Any ideas?


Try starting your sub activities B and C with the flag FLAG_ACTIVITY_NO_HISTORY.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜