CustomExceptionHandler
public class CustomExceptionHandler implements UncaughtExceptionHandler {
private Context ctx;
private ContentResolver cr;
public CustomExceptionHandler(Context ctx, ContentResolver cr) {
this.ctx = ctx;
this.cr = cr;
}
public void uncaughtException(Thread t, Throwable e) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
e.printStackTrace(printWriter);
String stacktrace = result.toString();
printWriter.close();
String deviceUuid = Utilities.DeviceUuid(ctx, cr);
String bluetoothName = Utilities.LocalBluetoothName();
AsyncTasks.ErrorLogTask logTask = new AsyncTasks.ErrorLogTask(e, bluetoothName, deviceUuid, stacktrace);
logTask.execute();
}
}
Called from my main activity:
Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(getBaseContext(), getContentResolver()));
When an exception occurs now, i dont get the regular "unfortunately, has stopped" popup. Its just a black screen. If i remove my call from my main activity, in other words dont use the CustomExceptionHandler
anymore, i get the default behaviour.
Is there any way to implement the default error behaviour in my class?
Thanks in advance!