Ich habe versucht, einen benutzerdefinierten UncaughtExceptionHandler in meine Anwendung zu implementieren, und ich habe die Bibliothek Ereza/CustomActivityOnCrash entdeckt.Ereza CustomActivityOnCrash startActivity with Intent
Ich habe den gesamten Code wie in der README (https://github.com/Ereza/CustomActivityOnCrash) beschrieben hinzugefügt, aber ich kann immer noch nicht scheinen, um es zum Laufen zu bringen. Wenn ich meine App zum Absturz zwinge, erscheint ein weißer Bildschirm und verschwindet sofort.
Irgendwelche Ideen, was könnte dies verursachen? unten ist einige meiner Code
AndroidManifest
<activity
android:name="com.test.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.test.MainActivity"
android:label="MainActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="cat.ereza.customactivityoncrash.RESTART" />
</intent-filter>
</activity>
<activity
android:name="com.test.ErrorActivity"
android:label="Error"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="cat.ereza.customactivityoncrash.ERROR" />
</intent-filter>
</activity>
Anwendungsklasse
public class TestApplication extends Application {
private static TestApplication mInstance;
private TimeZone usersDefaultTimeZone;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
//Customization for CustomActivityOnCrash
//Show (TRUE) or Hide (FALSE) the stack trace on the error activity
CustomActivityOnCrash.setShowErrorDetails(false);
//Enable Restart (TRUE) 'Restart App' button
//Disable Restart (FALSE) 'Close App' button
CustomActivityOnCrash.setEnableAppRestart(true);
//This sets a custom error activity class instead of the default one.
CustomActivityOnCrash.setErrorActivityClass(ErrorActivity.class);
//This sets a EventListener to be notified of events regarding the error activity,
//CustomActivityOnCrash.setEventListener(new CustomEventListener());
//Specify the Activity to to restart the application
CustomActivityOnCrash.setRestartActivityClass(MainActivity.class);
//Install CustomActivityOnCrash
CustomActivityOnCrash.install(this);
//Now initialize your error handlers as normal
Fabric.with(this, new Crashlytics());
}
public static synchronized TestApplication getInstance() {
return mInstance;
}
static class CustomEventListener implements CustomActivityOnCrash.EventListener{
@Override
public void onLaunchErrorActivity() {
Log.i("BookingApp", "onLaunchErrorActivity()");
Crashlytics.logException(new Exception("Unknown Exception Caught & Error screen displayed to user"));
}
@Override
public void onRestartAppFromErrorActivity() {
Log.i("BookingApp", "onRestartAppFromErrorActivity()");
Answers.getInstance().logCustom(new CustomEvent("Restart After Crash"));
}
@Override
public void onCloseAppFromErrorActivity() {
Log.i("BookingApp", "onCloseAppFromErrorActivity()");
Answers.getInstance().logCustom(new CustomEvent("Close After Crash"));
}
}
}
geben Sie bitte logcat –