Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get android background running process details

I want to list all background running processes and get details of those from one background service(Without UI). Details are as follows:

1. Name
2. Memory usage
3. Application related to process
4. Files they are accessing
5. Last modified time of files

I can get list of background running processes but how to get memory usage, Files they are accessing and Last modified time of files. Is this possible to implement at API level? Can anyone guide me How to do this? Can anybody give me idea or suggest useful link related to this.

like image 820
Balaji Khadake Avatar asked Nov 22 '11 11:11

Balaji Khadake


People also ask

How do I find out what background processes are running on my Android?

To see what apps are running in the background, go to Settings > Developer Options > Running Services.

What are cached background processes Android?

That being said, "cached background processes" usually refers to processes that do not have a foreground activity and do not have a running service. These processes are kept in memory simply because we have enough memory to do so, and therefore, as you note, the user can switch back to these processes quickly.

Which component is used to run long running background in Android?

Introduction To Android Services An Android service is defined as an application component that is generally used to perform long tasks in the background without needing user input.


2 Answers

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.

like image 76
hackbod Avatar answered Oct 10 '22 18:10

hackbod


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

like image 23
ANUP Avatar answered Oct 10 '22 17:10

ANUP