Android - 检查应用程序进程状态
如何以编程方式检查 Android 设备上运行的特定进程的状态(暂停/运行/挂起)?我想将这个逻辑包含在我的应用程序中。
使用 ActivityManager
,我能够检索设备上运行的所有进程的列表,但它不会向我显示任何进程状态信息。知道如何检索此信息吗?
提前致谢。
How can I check the state (pause/running/suspended) of a particular process running on the Android device programmatically? I want to include this logic within my application.
Using ActivityManager
, I am able to retrieve a list of all processes running on the device, but it doesn't show me any process state information. Any idea on how I can retrieve this information?
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我在问题中提到使用 ActivityManager 检索的进程列表中没有进程状态信息时,我错了。
ti.importance 检索一个常量值,该值描述进程是否正在运行前台、后台、空代码等...
更多信息可以在以下位置找到:
http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html
谢谢,
纳文
I was wrong when I mentioned in the question that there is no process state information in the list of processes retrived using ActivityManager.
ti.importance retrives a constant value which describes whether the process is running FOREGROUND, BACKGROUND, Empty of code etc...
More information can be found at the following location:
http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html
Thanks,
Navin
您可以遵循活动生命周期。将你的逻辑置于每个状态。不知道activity中是否有get状态。
You can follow the activity lifecycle. Put your logic in each state. I don't know if there is a get state in activity.