Track Force Close Alert(Exception)
When an exception occurs , an alert dialog with force c开发者_运维知识库lose & wait is showing. Can we redirect it to another page, by tracking the exception, without showing that force close.. Because after foece close the application will close.. How can we prevent that.
Can we redirect it to another page, by tracking the exception, without showing that force close
First, for all places where runtime exceptions are expected, handle them locally with a try
/catch
block.
Then, for everything else, use Thread
and setDefaultUncaughtExceptionHandler()
. This is great for connecting to ACRA, Flurry, or other services that will let you track crashes that occur in your application on your users' devices.
Because after foece close the application will close.
No, it doesn't. After "foece close" the component that had the exception (e.g., an activity) will be removed.
Bear in mind that if you have an unhandled runtime exception, you have no way of knowing if your application is in a useful state, so be very careful about what you do. Do not assume that you can just blindly return control to your application -- otherwise, you will wind up in an infinite loop of unhandled exceptions, frustrating your user.
You can register an UncaughtExceptionHandler to your application. With this it is possible to catch all the exceptions that are not handled anywhere else. Then it is to you what you do there in the handler. You can inform the user, silenty catch the exception, post to a website, etc.
Well, the force close is usually something you get when application stops responding.
If your application actually throws an exception, you can fetch that in code in a try/catch statement.
精彩评论