通过ADB Shell接受“强制关闭”对话框 [英] Accept 'Force Close' dialog via ADB shell

查看:345
本文介绍了通过ADB Shell接受“强制关闭”对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出当Android应用因硬错误(特别是out_of_memory)崩溃而通过adb shell接受(强制)对话框的方式(或是否可能)。我希望基本上可以使用bash脚本来循环应用程序,因此当它崩溃时,我想重新启动它。此处缺少的步骤是,我无法模拟按下对话框中间显示的强制关闭按钮。

I'm trying to figure out how (or if it's possible) to accept the 'Force Close' dialog via the adb shell when an Android app crashes with a hard error (specifically out_of_memory). I'm hoping to basically loop an app with a bash script, so when it crashes I want to start it running again. The missing step here is that I can't simulate pressing the 'Force Close' button that shows up in the middle of the dialog.

与此同时,该进程似乎并未真正运行(试图杀死PID无效),所以这有点奇怪因为它似乎已经停止,但是再次启动它(通过adb shell am ...)只是给了我当前任务已被置于最前面。

At the same time, the process doesn't seem to actually be running (trying to kill the PID doesn't work), so it's a bit of a weird situation because it seems to have already stopped, but launching it again (via adb shell am ...) just gives me 'current task has been brought to the front'.

任何想法都将不胜感激!

Any thoughts would be appreciated!

推荐答案

+1到 DarkXphenomenon 用于 UncaughtExceptionHandler

不过,您应该使用 上午

However to kill the process you should use 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 <YOUR.PACKAGE.NAME>

这篇关于通过ADB Shell接受“强制关闭”对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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