Android 如何获取所有正在运行的应用程序?不要跟我说网上搜的那些,在真机里根本就行不通!求来电实际的,靠谱的!谢谢!搜来粘贴的就不要回答了! |
|
40分 |
ActivityManager.getRunningAppProcesses()
ActivityManager.RunningAppProcessInfo pkgList 有图有真相。。。 |
请问是真机上测试的吗?求代码呀! |
|
小米3 4.4.2
List<ActivityManager.RunningAppProcessInfo> processList = mActivityManager .getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo appProcess : processList) { String[] pkgNameList = appProcess.pkgList; for (int i = 0; i < pkgNameList.length; i++) { String pkgName = pkgNameList[i]; Log.i("1", "packageName " + pkgName ); } } |
|
ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|