如何从“adb shell”终止本机应用程序?
我可以使用 am start -a action -n packagename/activity
启动本机应用程序。如何从 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
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Chirag 删除了它,所以又出现了:
这将在模拟器之外运行。这是一个很长的 Unix 命令,而不是四个视觉上分隔的命令。
|
是语法,由您的(Ubuntu 的)shell 解释,然后将 adb、grep 等的输出通过管道传输到下一个。模拟器中仅执行ps
。Chirag deleted it, so here it is again:
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. Onlyps
is executed in the emulator.终止应用程序的另一种方法是将应用程序发送到后台(使用主页按钮)并调用:
它并不适用于我的所有设备,但是,在它工作的设备上,其行为方式与应用程序在后台被终止相同由于缺乏资源,这种状态通常可以方便地测试流程重新创建的不同方面。
例如,如果您在清单中注册了广播接收器,它们仍然会启动而无需手动重新启动您的应用程序,与您可以使用以下方法实现的强制停止相比:
Another way to kill your app is to send your app to backround (using home button) and call:
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 中尝试以下命令。
Please try the below command in adb shell.