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 CatchAllExceptionHandle开发者_如何学Cr
:
- Display an Alert dialog
- 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?
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.
精彩评论