安卓得到其他应用程序的PID [英] Android get PID of other applications

查看:227
本文介绍了安卓得到其他应用程序的PID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够启动一个活动或服务,并得到该进程的PID尽快,立刻将是最好的情况。难道我比浏览/ proc目录,然后导致变额 - - 时间的竞争状态的活动/服务推出的时间,它需要我找什么,我想在proc时间之间的其它任何选项目录并开始观测?

I would like to be able to start an activity or service and get the PID of that process as quickly as possible, immediately would be the best case scenario. Do I have any options other than browsing the /proc directory, which then leads to a variable-amount-of-time race condition between the time the activity/service is launched and the time it takes me to find what I want in the proc directory and begin observing?

推荐答案

我想你可能需要使用ActivityManager:看<一href="http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html">http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html为过程信息。你可以:

I think you'd need to use ActivityManager: see http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html for the process info. You could:

  1. 在获取所有正在运行的应用程序的进程。
  2. 找到你的应用程序。
  3. 在获取它的PID。

这篇关于安卓得到其他应用程序的PID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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