Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

adb

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.

like image 660
AndroDev Avatar asked Jun 05 '12 11:06

AndroDev


People also ask

How can I tell if ADB server is running?

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.

How do I tell what services are running on my Android?

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.

How can I check my ADB status?

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."


2 Answers

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.

like image 66
user276648 Avatar answered Sep 20 '22 15:09

user276648


Try the command line

adb shell service list

I get a list of service names and their package names as well.

like image 39
Dr. Ferrol Blackmon Avatar answered Sep 19 '22 15:09

Dr. Ferrol Blackmon