1

There is a question how to implement uncaughtException android and best rated answer has code

System.exit(2);
defaultUEH.uncaughtException(thread, ex);

Is this really correct and this code should be executed? I've tested this on HotSpot and Dalvik, and looks like it is not really working. In witch environment does it works?

Community
  • 1
  • 1
alexandr.opara
  • 454
  • 2
  • 7

1 Answers1

0

System.exit() should never be called on an Android app. This won't close your application cleanly and it's a discouraged way of closing your app.

That said, the code probably tries to represent that the statement is not executed instantly, but it takes a time to close the app. Meanwhile, it might go on running code that's above from that line. It's a similar behavior as when you use finish() on an Activity. You can place code below of that line and it will be run as well.

nKn
  • 13,691
  • 9
  • 45
  • 62