开发者

How to test if my app behaves properly when Android OS kills its process?

How can I test whether my app behaves properly when Android OS kills its proces开发者_开发百科s due to low memory?


Just press the home button, you will be able to use onPause and to save your state use: onSaveInstanceState(Bundle) / onCreate(Bundle) to handle recovery.

More on Activities and it's life-cycle: http://developer.android.com/reference/android/app/Activity.html


I guess you can't actually do anything if the OS terminates the process (this usually happens when your application is already paused or stopped).

See http://developer.android.com/guide/topics/fundamentals.html#actlife


I guess you don't need the answer anymore, but I was looking for the same thing: Test onCreate after the Activity was destroyed by the OS.

Here is the simple solution at least for the Emulator: Open the "Dev Tools" in the app drawer of your emulator, select "Development Setting*s" and activate the checkbox "*Immediately destroy activities"

After this, open your app and leave it via the Home key. Thats it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜