android - 当内存不足时,android 会销毁单个 Activity 还是整个堆栈?

标签 android

正如标题所说,当 android 内存不足时究竟会发生什么?它是随机选择 Activity 并终止它们,还是终止应用程序的整个后台堆栈。

我担心我在我的应用程序中的 Activity 历史不会被妥善保存(例如,个人资料页面出现在编辑图片页面之前)

最佳答案

它杀死了整个过程,而不仅仅是一些 Activity 。如果操作系统决定终止您的应用程序正在运行的进程,您的应用程序将作为一个整体被终止。

如果你通过Processes and Application Lifecycle

In most cases, every Android application runs in its own Linux process. This process is created for the application when some of its code needs to be run, and will remain running until it is no longer needed and the system needs to reclaim its memory for use by other applications.

此外,如果您通过 Processes and Threads

By default, all components of the same application run in the same process and most applications should not change this. ... Android might decide to shut down a process at some point, when memory is low and required by other processes that are more immediately serving the user.

希望对您有所帮助。

关于android - 当内存不足时,android 会销毁单个 Activity 还是整个堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46435406/

相关文章:

android - Onkeydown return false 和 return super.onkeydown() 有什么区别?

java - 如何读取电池充电次数?

android - 仅发布适用于 Android v4.4.3+ 的应用程序?

Android,setSpan 两次?

android - 将数据库保存到android中的文件中

android - eclipse 安卓 : how to use a library project with linked folders?

java - 安卓 : Access raw resource as a File or a jetty Resource.

android - 将解析信息添加到 Robolectric 包管理器

java - System.out.println() 在某些行上缺少制表符 ("\t")

java - 渲染 ImageButtons 时出现 OutOfMemoryError