Skip to content Skip to sidebar Skip to footer

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:

  1. Get all running app processes.
  2. Find your app.
  3. 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)

Solution 3:

try this

intid= android.os.Process.myPid();

Post a Comment for "Android Get Pid Of Other Applications"