How to get android background running process details

邮差的信 提交于 2019-12-03 08:14:31

The Running Services UI uses getRunningAppProcesses, getProcessMemoryInfo, and getRunningServices.

Note that these only tell you about Java processes being managed by the high-level system; getRunningAppProcesses will not return information about low-level daemon processes.

The kernel has information about open files under /proc, but you can not get the information about another process unless you are running as root.

Also all currently running processes are under /proc, but please note that /proc is not a part of the Android SDK and there are no guarantees that your application will work across all devices or versions of the platform if using that. /proc is a private implementation detail.

ANUP

With following line of code you can get currently running services list

ActivityManager localActivityManager = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);

List RunningServiceInfoservices = localActivityManager.getRunningServices(100);

And from RunningServiceInfo you can get details for the process. http://developer.android.com/reference/android/app/ActivityManager.RunningServiceInfo.html

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