「Android入門」プロセスIDを取得するコード

サンプルコード
ActivityManager mActivityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> mRunningProcess = mActivityManager.getRunningAppProcesses();

int i = 1;
for (ActivityManager.RunningAppProcessInfo amProcess : mRunningProcess) {
Log.e(“homer Application", (i++) + "  PID = " + amProcess.pid + “; processName = " + amProcess.processName);
}

Android

Posted by arkgame