2

If I do a regular Java application then all exceptions which uncaught, get propagated in main thread and I can catch them here. However I do not see how I can use that in Android application. Let's say I have some third party library which uses some JDK 1.6 API and access to these API generates unhandled exception which crashes my application. Since I do not have direct control of thread creations in third party libraries, I can't use Thread.UncaughtExceptionHandler. So what's way to catch such exception and notify a user without crashing application?

Dmitriy
  • 21
  • 2

1 Answers1

3

Just set a default exception handler for all threads

mibollma
  • 14,959
  • 6
  • 52
  • 69
  • 1
    This isn't guaranteed to work. It is possible for the `ThreadGroup` containing the third party thread to catch the error and call `System.exit()` (or whatever the Android equivalent is). –  Jun 29 '11 at 05:39
  • True. But that's just very bad library design. – mibollma Jun 29 '11 at 12:08