Debug: Show fatal error on launcher crash

This commit is contained in:
khanhduytran0 2020-08-08 09:11:02 +07:00
parent 9d4b607003
commit 5b12c7bfb4
2 changed files with 18 additions and 1 deletions

View File

@ -1,10 +1,19 @@
package net.kdt.pojavlaunch;
import android.support.v7.app.*;
import android.content.*;
import android.os.*;
import android.support.v7.app.*;
public class FatalErrorActivity extends AppCompatActivity
{
public static void showError(Context ctx, Throwable th) {
Intent ferrorIntent = new Intent(ctx, FatalErrorActivity.class);
ferrorIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
ferrorIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ferrorIntent.putExtra("throwable", th);
ctx.startActivity(ferrorIntent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@ -14,6 +14,14 @@ public class PojavApplication extends Application
{
@Override
public void onCreate() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){
@Override
public void uncaughtException(Thread thread, Throwable th) {
FatalErrorActivity.showError(PojavApplication.this, th);
android.os.Process.killProcess(android.os.Process.myPid());
}
});
try {
super.onCreate();
Tools.APP_NAME = getResources().getString(R.string.app_short_name);