[英]android process still alive after finishing activities
My application launches 3 activities.我的应用程序启动了 3 个活动。 When I want to exit, I close these 3 activities calling finish method.
当我想退出时,我关闭这 3 个调用完成方法的活动。 The activity onDestroy methods are then called but the process is still alive... How is it possible?
然后调用活动 onDestroy 方法,但该过程仍然存在......这怎么可能?
This is perfectly normal.这是完全正常的。 Android will keep your process around until such time as it needs to reclaim that process' memory.
Android 将保留您的进程,直到它需要回收该进程的 memory。 That way, if the user immediately returns to your application, your application will appear quicker -- Android does not have to fork a process and load your application into memory.
这样,如果用户立即返回到您的应用程序,您的应用程序将显示得更快——Android 不必派生一个进程并将您的应用程序加载到 memory 中。
Try:尝试:
System.exit(0);
It will kill your Activity-process.它会杀死你的活动进程。
Edit: As mentioned in the comments below.编辑:如以下评论中所述。 This works much better: android.os.Process.killProcess(android.os.Process.myPid());
这效果更好: android.os.Process.killProcess(android.os.Process.myPid());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.