Android Get Pid Of Other Applications
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 o
Solution 1:
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:
- Get all running app processes.
- Find your app.
- Get its PID.
Solution 2:
ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> pidsTask = activityManager.getRunningAppProcesses();
for(int i = 0; i < pidsTask.size(); i++) {
nameList.add(pidsTask.get(i).processName);
idList.add(pidsTask.get(i).uid);
}
pidsTask.get(i).uid // Return PID for Apps(Process)
Post a Comment for "Android Get Pid Of Other Applications"