1: 获取PackageManager 获取全部静态已安装的应用:
1 | PackageManager pm = getPackageManager(); <br>List<PackageInfo> infos = pm.getInstalledPackages( 0 ); <br><br>icon : info.applicationInfo.loadIcon(pm)<br>appName : info.applicationInfo.loadLabel(pm) |
2:获取ActivityManager获取动态所有正在运行的进程
1 2 | ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> infos = am.getRunningAppProcesses();<br><br>info.processName + " ; " + info.uid + " ; " + info.pid |
1 | 类似如下输出: |
10-20 13:43:16.047: I/System.out(28009): com.qihoo360.mobilesafe:FloatWindow ; 10057 ; 27991
10-20 13:43:16.047: I/System.out(28009): com.qihoo360.mobilesafe:GuardService ; 10057 ; 25390 10-20 13:43:16.047: I/System.out(28009): com.qihoo360.mobilesafe:clear ; 10057 ; 27532