如何獲取當前應用app所在的程序id和程序名稱
阿新 • • 發佈:2019-02-02
int pid = Process.myPid(); String processName = ""; ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> list = activityManager.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : list){ if (runningAppProcessInfo.pid == pid){ processName = runningAppProcessInfo.processName; } } Log.i(TAG,"當前程序名稱:" + processName);