Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用当前的命令行工具(adb, am, pm)来模拟用户从设置应用程序中按下强制停止?从 shell调用kill <pid>只能很好地模拟系统终止进程时发生的情况,但强制停止通过删除ActivityRecordAndroid 保存的实例来删除应用程序的内存。
adb
am
pm
kill <pid>
ActivityRecord
有没有我们可以调用的 shell 命令来模拟同样的行为?
干杯。
使用am:
am force-stop: force stop everything associated with <PACKAGE>. am kill: Kill all processes associated with <PACKAGE>. Only kills. processes that are safe to kill -- that is, will not impact the user experience.
例如:
adb shell am force-stop <PACKAGE>