Java tutorial
//package com.java2s; import android.app.ActivityManager; import android.content.Context; public class Main { public static String getRunningAppNameByPID(Context context, int pid) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { if (processInfo.pid == pid) return processInfo.processName; } return null; } }