Reputation: 3585
In Windows phone 7, developers are provided an Application_UnhandledException event that provides an exception object containing information and stack trace of any unhandled exception that occurs. There is an opportunity to store this object in local storage. On next startup we can check for such an object and email it to the developer. Obviously this is valuable in diagnosing production crashes.
Does such a thing exist in Android? Thanks, Gary
Upvotes: 3
Views: 2819
Reputation: 786
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"
Upvotes: 0
Reputation: 161
java.lang.Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler handler)
Is this what you want?
Upvotes: 8