How to kill native applications from 'adb shel

2019-02-03 19:42发布

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?

标签: android adb
4条回答
beautiful°
2楼-- · 2019-02-03 19:45

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
查看更多
Root(大扎)
3楼-- · 2019-02-03 19:55
adb shell am force-stop packagename
查看更多
霸刀☆藐视天下
4楼-- · 2019-02-03 19:58

Please try the below command in adb shell.

adb shell kill <PID>
查看更多
一纸荒年 Trace。
5楼-- · 2019-02-03 20:03

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.

查看更多
登录 后发表回答