简体   繁体   中英

How to monitor background services for apps in Android devices?

Lately I have installed several apps for the purpose of Android development and testing. I noticed that my phone has been draining in battery more than before even while apps were not open and active. Is there an Android tool that will help me identify which apps are using background services? And if so, will the tool provide me detail on how much bandwidth application A is using compared to application B? I am interested in knowing if an app is using broadcast receivers, services, etc. incorrectly. I'd also like to use this tool for myself when developing an app to know if I am wasting too many cpu cycles, or memory that might lead to battery draining. Thank you!

You can use dumpsys.

For example:

$ adb shell dumpsys activity

Will display all information about currently running activities, services, registered broadcast receivers, pending intents, and so much more.

You can also dump information from batterystats service:

$ adb shell dumpsys batterystats

It will show any currently held wakelocks. To see all services available to dump you can use:

$ adb shell service list

UPDATE :

dumpsys is very hardcore. I don't know any GUI tools. The best thing I can advice to you is to read the source code of Binder#dump methods.

For example, here is ActivityManagerService dump method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM