Cannot get all running Android processes

耗尽温柔 提交于 2021-02-08 11:19:33

问题


I want to get all running processes in my phone. I have tried this code

ActivityManager am = (ActivityManager) 
                     getBaseContext().getSystemService(Context.ACTIVITY_SERVICE);

List<ActivityManager.RunningAppProcessInfo> pids = am.getRunningAppProcesses();

But this code returns only my process.


回答1:


ActivityManager am = (ActivityManager)this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> listProcess = am.getRunningAppProcesses();
for(RunningAppProcessInfo runningProInfo:listProcess){
        Log.i("Running Processes", ":"+runningProInfo.processName);
}

Working code.

Hope this helps..



来源:https://stackoverflow.com/questions/39097007/cannot-get-all-running-android-processes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!