首先在Android中获取系统正在运行的进程方法是getRunningAppProcesses()。我们首先通过ActivityManager manager= (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);来获取系统的全局状态,然后通过调用getRunningAppProcesses()方法就可以获得系统正在运行的进程, 代码如下:
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> list =manager.getRunningAppProcesses();
for (int j = 0; j < list.size(); j++) {
Log.i(j+"", list.get(j).processName);
}
list.get(j).processName得到系统下在运行的包名+入口的Activity