停止从控制台的Andr​​oid应用 [英] Stopping an Android app from console

查看:187
本文介绍了停止从控制台的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能停止从控制台一个Android应用程序?是这样的:

Is it possible to stop an Android app from the console? Something like:

adb stop com.my.app.package

这将加快我们的测试过程这么多。现在,我们卸载/每次安装应用程序,以确保手动测试开始用干净的状态。

It would speed up our testing process so much. Right now we uninstall/install the app each time to make sure the manual test cases start with a clean state.

推荐答案

编辑:龙后,我写了这篇文章,被接受的答案,在时力 - 停止命令是实施通过Android团队,正如在回答以下

Long after I wrote this post and it was accepted as the answer, the am force-stop command was implemented by the Android team, as mentioned in the answer below.

或者而不是只停止应用程序,既然你提到想要一个清白每次测试运行,你可以使用亚行外壳时明确com.my. app.package ,这将阻止应用程序的的清除该应用中的所有存储数据。

Alternatively: Rather than just stopping the app, since you mention wanting a "clean slate" for each test run, you can use adb shell pm clear com.my.app.package, which will stop the app process and clear out all the stored data for that app.

如果您在Linux上:
亚行外壳PS | grep的com.myapp | awk的'{打印$ 2}'| xargs的亚行外壳杀

If you're on Linux:
adb shell ps | grep com.myapp | awk '{print $2}' | xargs adb shell kill

这将仅适用于在那里你在运行一个shell中立即有根的设备/仿真器。这也许可以稍微细化调用先。

That will only work for devices/emulators where you have root immediately upon running a shell. That can probably be refined slightly to call su beforehand.

另外,你可以做(​​手动,或者我猜想脚本):
PC $ ADB -d壳
安卓$苏
安卓#PS
安卓#杀<从ps输出&GT进程id;

Otherwise, you can do (manually, or I suppose scripted):
pc $ adb -d shell
android $ su
android # ps
android # kill <process id from ps output>

这篇关于停止从控制台的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆