Search code examples
androidshelladb

How to detect running app using ADB command


I have one Android Device running Jelly Bean OS.

Is there any way to detect the process is running or not using ADB command if i know the package name?


Solution

  • No need to use grep. ps in Android can filter by COMM value (last 15 characters of the package name in case of java app)

    Let's say we want to check if com.android.phone is running:

    adb shell ps m.android.phone
    USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
    radio     1389  277   515960 33964 ffffffff 4024c270 S com.android.phone
    

    Filtering by COMM value option has been removed from ps in Android 7.0. To check for a running process by name in Android 7.0 you can use pidof command:

    adb shell pidof com.android.phone
    

    It returns the PID if such process was found or an empty string otherwise.