Hi, I want to intercept all exceptions with a global exception with a
AlerDialog but my UncaughtExceptionHandler doesn't seems to show the
dialog. Did I implement it correctly?

Many Thanks.

I put this in onCreate() ->
Thread.setDefaultUncaughtExceptionHandler(onDirectoryException);

---
The I implemented Thread.UncaughtExceptionHandler ->

        private Thread.UncaughtExceptionHandler onDirectoryException = new
Thread.UncaughtExceptionHandler() {
                String LOG_TAG;
                @Override
                public void uncaughtException(Thread thread, Throwable ex) {
                        // TODO Auto-generated method stub
                        Log.e(LOG_TAG, "Directory parsing or data connection 
timeout", ex);
                        new AlertDialog.Builder(getBaseContext())
                                .setTitle("Information")
                                .setMessage("Data connection timeout. Please 
try again later.")
                                .setPositiveButton(android.R.string.ok, null)
                                .setCancelable(false)
                                .create()
                                .show();
                        finish();
                }
        };

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to