Android – How to know whether service is running using adb shell in android

adbandroid

I want to know whether media player service (registers with media.player when device boots up) is running or not using adb shell. Is it possible?

I tried running ps command but no success.

Best Solution

As mentioned already, adb shell service list will only list system services.

As explained in Android Emulator: How can I get a list of services that are running, you can look for services created by apps by using

// List all services
adb shell dumpsys activity services

// List all services containing "myservice" in its name
adb shell dumpsys activity services myservice

If it returns something, it means the service is installed. To know if the service is currently started or stopped, look for app=ProcessRecord(...) or app=null respectively.

You can also do it Linux style with a simple

ps | grep myservice

while inside of your shell.