views:

97

answers:

1

I want to detect when an uncaught exception has happened in my Android app. Once detected, I want to display a confirmation dialog

How do I get this confirmation dialog to display? When I tried various techniques, the UI is unresponsive and appears to be frozen.

My code responds to this:

//new CatchAllExceptionHandler(this) is my custom handler Thread.setDefaultUncaughtExceptionHandler(new CatchAllExceptionHandler(this));

I have tried these two implementations of CatchAllExceptionHandler:

  1. Display an Alert dialog
  2. Start an activity that then displays an alert dialog after onCreate

Both these methods failed.

So my question is: How to I get the confirmation dialog to properly display?

+2  A: 

You may be attempting to do your UI operations on a non-UI thread. Use any of the available techniques (Handler, Handler#post, View#post, Activity#runOnUiThread, AsyncTask#onPostExecute) to arrange for your UI work to be done on the UI thread.

CommonsWare
runOnUiThread failed
gregm