Search code examples
javaandroidshellandroid-studioadb

How to close an app and test its background processes with ADB shell


Trying to close an application and monitor it's background processes on debugger, is this possible with adb shell?


Solution

  • How to check the app is running-

    Below command gives all running process on your device.

    adb shell ps 
    

    In case above command doesn't show all running process, use below command.

    adb shell ps -A
    

    grep your app by giving app name or any part of your app process name.

    adb shell ps | grep <app/process name>
    

    Get the pid(the number in second column of above command's output) of your running app from output of above command and kill the app by its process id

    adb shell kill -9 <app pid>