Search code examples
androidexceptionuncaughtexceptionhandler

How to get logcat in UncaughtExceptionHandler


I'm writing a custom exception handler that basically reports every crash of an application and i want to get logcat output after an exception occurs. That's the easy part, i just use

Runtime.getRuntime().exec("logcat -d");

But that only gives me all of the logcat that occured prior to the exception, e.g. i dont get the FATAL part of the exception. So if my app crashes two times i will get the first FATAL signal in the second crash.

Is there a way around this? Using a Thread.sleep is not really an option, unless the sleep is really small, but that seems kind-of hackish...


Solution

  • Is there a way around this?

    Capture the stack trace of the Exception that you caught.