Reputation: 156
I am wondering if it is possible to change the crash message for android?("unfortunately app has stopped") I haven't found anything that says you can(which I don't think you can), I am just making sure by asking on here.
Thanks
Upvotes: 3
Views: 484
Reputation: 14775
You cannot change the system message as stated by @Nuno Gomes but you can suppress the original message and display a message on your own or start some activity.
You can define an exceptionhandler that catches all uncaught exceptions in app class and show a message box from there
public class MyApp extends Application implements Thread.UncaughtExceptionHandler {
private Thread.UncaughtExceptionHandler mPreviousUncaughtExceptionHandler;
@Override public void onCreate() {
super.onCreate();
mPreviousUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(this);
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
try {
// Do your stuff with the exception
Log.e(Global.LOG_CONTEXT,"LogCat.uncaughtException " + ex, ex);
// show user defined messagebox
} catch (Exception e) {
/* Ignore */
} finally {
// uncomment this to let Android show the default error dialog
// mPreviousUncaughtExceptionHandler.uncaughtException(thread, ex);
}
}
}
the app must be declared in the manifest
<manifest ...>
...
<application
android:name=".MyApp" ...>
</application>
</manifest>
On my android-4.4 i use this code to write a chrash log file
Upvotes: 3
Reputation: 159
That message is a system message, it's outside the app scope, so no you cannot change it
Upvotes: 2