RanjitRock
RanjitRock

Reputation: 1441

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?

Upvotes: 8

Views: 34021

Answers (4)

Gaket
Gaket

Reputation: 6829

Another way to kill your app is to send your app to backround (using home button) and call:

adb shell am kill com.your.package

It works not on all of my devices, however, on devices where it works it behaves the same way as if the app was killed in background due to lack of resources and this state is often handy to test different aspects of your process recreation.

For example, if you have Broadcast Receivers registered in Manifest, they will still start without restarting your app manually, comparing to force stop that you can achieve using:

adb shell am force-stop com.your.package

Upvotes: 7

Tema
Tema

Reputation: 4181

adb shell am force-stop packagename

Upvotes: 34

Julian Fondren
Julian Fondren

Reputation: 5619

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.

Upvotes: 11

Chirag
Chirag

Reputation: 56925

Please try the below command in adb shell.

adb shell kill <PID>

Upvotes: 1

Related Questions