How to emulate the process of a background activity is killed by the system because of low memory on Android?

99封情书 提交于 2020-01-04 04:16:25

问题


I'm dealing with the "Low memory: no more background process" problem. My activity is at background and killed when the situation occurs.

I'm trying to save and load the instance state to solve it.

But since it doesn't happen every time. How should I test my activity with this situation?

Thanks!


回答1:


You can force your process to die through adb.

> adb shell
# ps
# kill -9 <pid>

where <pid> is the process id of your app. Caveat: I don't know if this method of ending the process is the same as when the OS decides it needs more resources.

Another approach might be to do it through Settings (click on your app under Application Management and then on the Force Stop button).



来源:https://stackoverflow.com/questions/5075773/how-to-emulate-the-process-of-a-background-activity-is-killed-by-the-system-beca

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!