1. 获取pidjava
int pid = android.os.Process.myPid();
2. 获取进程名及其余信息
ActivityManager mActivityManager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager
.getRunningAppProcesses()) {
if (appProcess.pid == pid) {
procName = appProcess.processName;
}
}
appProcess中能够获取一些进程相关的信息,如:
/**
* The name of the process that this object is associated with
*/
public String processName;
/**
* The pid of this process; 0 if none
*/
public int pid;
/**
* The user id of this process.
*/
public int uid;
/**
* All packages that have been loaded into the process.
*/
public String pkgList[];
/*