2

I do a research about Android Activity lifecycle. And I know after an app goes to background, it is likely to be killed by system if apps with higher priority need memory, but save the activity with a bundle. And when users come back, system will restore it, that makes user feel good!

I want to know how to make this circumstance, I want to see my application to be killed before hand, not see it when it is used by users, to evaluate whether it is strong or not. Because it may be crashed when this happens.

kidoher
  • 2,297
  • 2
  • 12
  • 19

2 Answers2

3

Enable "Don't keep activities" in the developer options on your phone. This will force kill your app as soon as you put it in the background.

See this question for more detail about how it works: Whats the main advantage and disadvantage of "do not keep activities" in android

See here for more info on how to enable it: http://www.pcadvisor.co.uk/how-to/google-android/3590299/32-useful-things-you-can-do-in-android-developer-options/

Community
  • 1
  • 1
gkee
  • 771
  • 1
  • 7
  • 11
  • Thank you very much, this helps me a lot. However, I need more to solve this problem. Even thought I switch that on, there is not memory shortage that forced the system to actually remove the object from memory. That is to say it doesn't build the situation that my application is killed by system in memory shortage. – kidoher May 06 '15 at 07:40
0

You can emulate it by sending your app to background and killing it by adb shell am kill your.package.name.

snak
  • 6,483
  • 3
  • 23
  • 33