如何检查,如果我的应用程序正在运行我的、应用程序、正在运行

2023-09-12 04:53:11 作者:我是你口中的别人.

我如何检查我的Andr​​oid应用程序已经运行至prevent双启动?

我怎样才能让严出,以prevent在后台运行我的应用程序?

解决方案

有不可能有双发射。如果你尝试启动另一个实例,比你恢复的首次发射情况下,你的应用程序已经在运行。

您可以通过添加 .finish()在所有情况下,当应用程序可以在 onPaused()序列的生命周期或添加完成() onPaused()

华为手机如何查看后台运行的应用程序

How can i check if my android app is already running to prevent double launch?

How can i make "hard exit" to prevent my app running on background?

解决方案

It is not possible to have "double launch". If you application is running already, if you try to launch another instance, than you'll resume the first launch instance.

You can finish activity by adding .finish() in all scenarios when application can be in onPaused() sequence of the lifecycle or add finish() in onPaused()