Hello Vivek - it sounds like you're on the right path. When you override
the uncaughtException() method, add in a Thread.sleep() in order to keep
your Activity from getting closed immediately.
Below is an example of what your uncaughtException() method might look
like...
@Override
public void uncaughtException(Thread thread, Throwable e) {
e.printStackTrace();
try {
displayErrorMessageToast();
Thread.sleep(3500);
} catch (Exception e1) {
Log.e(TAG, "Error: ", e1);
} finally {
killApplicationProcess(e);
}
}
Your "displayErrorMessageToast()" method would then implement the toasting
portion that it sounds like you've already tried to do.
Hopefully this help!
-Matt
www.sep.com/mcterry
On Thursday, March 22, 2012 12:44:15 AM UTC-4, Vivek Khandelwal wrote:
>
> I want my Application to show Custom Dialog When an Uncatch Exception
> occur.
>
> For that reason, I am implementing
> Thread.​setDefaultUncaughtExceptionHan​dler.
>
> I am successfully able to handle all my uncatch Exceptions.
>
> And Try to show the Toast.
>
> But My Toast is not Displayed because my Main Looper (i.e My Main Thread)
> is being stopped and My Whole Application get blocked.
>
> I tried to create a Alternate Main Looper when Main Looper is being
> stopped. But for some reason my Alternate Main Looper does not get Any
> Message in MessageQueue.
>
> Is there any other way to do that.
>
> What I need is to Show the Error to User and Close the Erroneous Activity,
> Not my Whole Application.
>
> Or Else is there any way that I can Handle all the uncatch Exception in an
> Activity.
>
--
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