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.
Followup: you can check MotionEvent. getDeviceId() ... it returns zero for input by the adb! All 3 methods here will not tell you whether a device is connected to a PC actively running adb . Just disconnected my device, and running all commands in an on-device terminal emulator shows adb is still running.
Back in Settings, head into Developer Options. You should see “Running services” a little way down this menu—that's what you're looking for. Once you tap “Running services,” you should be presented with a familiar screen—it's exactly the same one from Lollipop.
You can verify that your device is connected by executing adb devices from the android_sdk /platform-tools/ directory. If connected, you'll see the device name listed as a "device."
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.
Try the command line
adb shell service list
I get a list of service names and their package names as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With