How to have a globalErrorHandler in Android

Hello,

I’m trying to add a global error handler in Android.
My current approach is shown below

    final Thread.UncaughtExceptionHandler oldHandler = Thread.getDefaultUncaughtExceptionHandler();
    Log.wtf("ErrorTest", "Wassup");
    Thread.setDefaultUncaughtExceptionHandler(
            new Thread.UncaughtExceptionHandler() {
                @Override
                public void uncaughtException(
                        Thread paramThread,
                        Throwable paramThrowable
                ) {
                    //Do your own error handling here
                    Log.wtf("ErrorTest", "Caught Error");
                    if (oldHandler != null)
                        oldHandler.uncaughtException(
                                paramThread,
                                paramThrowable
                        ); //Delegates to Android's error handling
                    else
                        System.exit(2); //Prevents the service/app from freezing
                }
            });

For some reason the log Caught Error doesn’t show up.
I wanted to add a way to send this error events through GameAnalytics. But the above code doesn’t execute. I have a feeling that it has to do something with Threading.
Can someone please let me know what’s going wrong?

@linrm, @pandamicro, any idea on this?