Resources:
Http://blog.csdn.net/hehe9737/article/details/7662123
Http://www.apkbus.com/android-128270-1-1.html
Http://www.cnblogs.com/freeliver54/archive/2011/10/17/2215423.html
Thread.setdefaultuncaughtexceptionhandler (New Uncaughtexceptionhandler () {//) sets a handler for the main thread to handle run-time exceptions
public void uncaughtexception (thread thread, final Throwable ex) {
Ex.printstacktrace ();
When the program appears crash, it will enter here, you can do some operations here, and then put System.exit (0);
//
}
});
public static void Setdefaultuncaughtexceptionhandler (Thread.uncaughtexceptionhandler eh) sets when a thread terminates abruptly because of an uncaught exception. And there is no default handler that is called when other handlers are defined for the thread.
Uncaught exception handling is first controlled by the thread, then controlled by the thread's Threadgroup object, and finally by the uncaught default exception handler. If the thread does not set an explicit uncaught exception handler, and the thread Group of the thread (including the parent thread group) does not specifically specify its Uncaughtexception method, the default handler's Uncaughtexception method is called.
By setting the default exception handlers that are not caught, the application can change the uncaught exception handling (such as logging to a specific device or file) for threads that have accepted any "default" behavior provided by the system.
Note that the default exception handler that is not caught should generally not conform to the thread's Threadgroup object, because this can lead to infinite recursion.
Parameters:
Eh-the object that is used as the default exception handler that is not caught. If NULL, there is no default handler.
static void Setdefaultuncaughtexceptionhandler (Thread.uncaughtexceptionhandler eh)
Set a default handler for a thread that is called when the program cannot be captured and exits, and if there are other handler
So as long as the set method, a handler for a thread can be in the program to exit the exception, the catch exception,
Http://www.eoeandroid.com/thread-167271-1-1.html
In JDK5.0, we can set a uncaughtexceptionhandler for any thread by Setuncaughtexceptionhandler the instance method of thread.
Of course you can also set a default uncaughtexceptionhandler for all thread, by calling Thread.setdefaultuncaughtexceptionhandler ( Thread.uncaughtexceptionhandler eh) method, which is a static method of thread.
Android uses Uncaughtexceptionhandler to catch global exceptions