简体   繁体   English

android 进程在完成活动后仍然存在

[英]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.

相关问题 如果某个进程在其活动仍然存在时被杀死了怎么办? - What if a process has been killed while its activities are still alive? Android上的Espresso 2,在先前测试的活动仍然存在的情况下,无法启动被测活动后,中间测试失败 - Espresso 2 on Android, intermediately tests fail after failing to start the activity under test while activities from previous tests are still alive Android完成以前的导航活动 - Android finishing previous activities for navigation 完成交易后完成所有活动 - finishing all the activities after completing a transaction 应用程式被杀死后,片段仍然存在(Android) - Fragment is still alive after app has been killed (Android) 即使在调用onDestroy()之后,Android服务仍然存在吗? - Is the Android service still alive even after the onDestroy() be called? Android:为什么活动结束后PhoneCallListener仍然存在? - Android : why PhoneCallListener still alive after activity finish? Android asynctask未完成其过程 - Android asynctask not finishing its process 在 onDestroy 之后 Loader 还活着 - Loader is still alive after onDestroy 即使在任务管理器杀死进程后,也要保持android警报活动 - Keep android alarms alive, even after process killed by a task manager
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM