简体   繁体   English

当我的应用程序在后台运行时,如何让 android 系统杀死我的应用程序?

[英]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.

相关问题 当我的应用程序在Android中运行时,如何打开Wifi? - How can I turn Wifi on when my application runs in Android? Android系统。 在系统将其杀死之后,如何保持应用程序运行。 或者如何不让系统杀死它 - Android. How to keep an application running after the system is going to kill it. Or how not to let the system to kill it android系统杀死应用程序时如何保存我的应用程序状态? - How to save my app state when android system kill the app? 如何终止该应用程序? - How can I kill the application? 当我杀死我的应用程序时,BroadcastReceiver无法正常工作 - BroadcastReceiver not working when I kill my application 有可能吗?,应用程序获取位置数据的纬度和经度,android系统无法杀死它,它在屏幕关闭时有效吗? - Is it possible ?, the application gets location data latitude and longitude, android system can not kill it, and it works when the screen is off? 当我更改活动以继续计算 Android Studio 中的时间时,如何让我的计时器计数? - How can I let my Timer Count when I change the activity to keep counting the time in Android Studio? 当我的android应用程序出现异常时如何杀死我的应用程序中的所有活动。 - When Exception came in my android application How to kill all activity's in my application. 为什么我在Android系统中杀死一个应用程序,但是又重新启动 - why i kill an application in android system,but it restart again 如何让用户在我的 android 应用程序中保持登录状态 - How can I let users remain logged in my android app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM