Search code examples
androidadb

How to kill native applications from 'adb shell'?


I am able to start native applications using am start -a action -n packagename/activity. How can I kill/stop a native application from adb shell?


Solution

  • Chirag deleted it, so here it is again:

    adb shell ps | grep com.myapp | awk '{print $2}' | xargs adb shell kill
    

    This is to be run outside of the emulator. It is one long Unix command, not four commands with a visual separation. | is syntax, interpreted by your (Ubuntu's) shell, which then pipes the output from adb, grep, etc., into the next. Only ps is executed in the emulator.