简体   繁体   English

我如何模仿一个Android进程成为后台进程?

[英]How can I mimic an android process becoming a background process?

I have crashes occurring in my app when the drops in the LRU-application list within androids OS (See http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle ). 当androids操作系统中的LRU-application列表下降时,我的应用程序发生崩溃(请参阅http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle )。 This is due savedInstanceStates not being handled properly. 这是由于saveInstanceStates不能正确处理。 It's really painful and time consuming to constantly have to open my app and then open like ten other applications just to mimic these errors and verify my fixes. 经常不得不打开我的应用程序,然后像其他十个应用程序一样打开它们,以模仿这些错误并验证我的修复程序,这确实是痛苦且耗时的。

Is there a quick way to mimic this via code? 有没有一种快速的方法可以通过代码模仿呢?

The way I test those cases is go to Settings > Developer Options . 我测试这些情况的方法是转到“设置”>“开发人员选项” Scroll to the very bottom and enable Don't keep activities . 滚动到最底部并启用“ 不要继续活动” Also, set the Background process limit to No background processes . 另外,将“ 后台进程限制”设置为“ 无后台进程”

Open your app and hit the home button once you are in the activity you want to test and then bring it back from the Recent Apps list. 进入要测试的活动后,打开您的应用程序并单击主页按钮,然后将其从“最近使用的应用程序”列表中恢复。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM