[英]How can I let android system kill my application when it runs in backgroud?
I do a research about Android Activity lifecycle .我做了一个关于 Android Activity 生命周期的研究。 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.
因为发生这种情况时它可能会崩溃。
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有关其工作原理的更多详细信息,请参阅此问题: 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/有关如何启用它的更多信息,请参见此处: http : //www.pcadvisor.co.uk/how-to/google-android/3590299/32-useful-things-you-can-do-in-android-developer -选项/
您可以通过将您的应用程序发送到后台并通过adb shell am kill your.package.name
杀死它来模拟它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.