如何检查,如果我的应用程序正在运行 [英] How can i check if my app is running

查看:184
本文介绍了如何检查,如果我的应用程序正在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

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

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

解决方案

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

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

这篇关于如何检查,如果我的应用程序正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆