如何模拟后台活动的进程被终止,因为在Android内存不足的系统?后台、进程、内存不足、系统

2023-09-12 22:23:57 作者:20.茶陌

我处理了内存不足:没有更多的后台进程的问题。 我的活动是在背景和遇难的情况发生。

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?

谢谢!

推荐答案

您可以强迫你的过程中,通过亚行不行了。

You can force your process to die through adb.

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

其中,&LT; PID&GT; 是您的应用程序的进程ID。警告:我不知道是否结束过程的该方法是一样的,当在OS​​决定它需要更多的资源

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).