Handle Unhandled Exceptions In Android
In Windows phone 7, developers are provided an Application_UnhandledException event that provides an exception object containing information and stack trace of any unhandled except
Solution 1:
java.lang.Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler handler)
Is this what you want?
Solution 2:
Extend Application class
import android.app.Application;
import android.util.Log;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Log.e("MyApplication", ex.getMessage());
}
});
}
}
Add the following line in AndroidManifest.xml file as Application attribute
android:name=".MyApplication"
Post a Comment for "Handle Unhandled Exceptions In Android"