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.
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!
If it is your own app, you can add an UncaughtExceptionHandler and not show the force close dialog. If not, the following might work.
You can also kill the process from adb. (Credit)
After that, you can use
adb shell am ...
to respawn the process.+1 to DarkXphenomenon for the UncaughtExceptionHandler.
However to kill the process you should use am:
for example: