开发者

Automatically Relaunch Application On Crash?

开发者 https://www.devze.com 2023-02-06 10:52 出处:网络
On Android, I\'m running an application using the NDK that runs a series of tests in C++. If ever one of the tests fails, which most likely means a crash, I\'d lik开发者_开发问答e the application to r

On Android, I'm running an application using the NDK that runs a series of tests in C++. If ever one of the tests fails, which most likely means a crash, I'd lik开发者_开发问答e the application to relaunch itself and start at the next test.

I wish I could use exceptions but the NDK doesn't support them.

Is this possible?


  1. Why does your application have to crash? Why not catch any exception being thrown? Even the compiler doesn't enforce you to add a try..catch block, RuntimeExceptions might still be thrown.
  2. You can also use Thread.setDefaultUncaughtExceptionHandler. Note that this must be called per thread.
  3. If, for some reason, the solutions above are not suitable for you, you could create a background service that acts as a watchdog timer.

EDIT: Check this link: for a custom version of the NDK that supports C++ exceptions. I found it in this thread.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号