diff options
author | xC3FFF0E <78732474+xC3FFF0E@users.noreply.github.com> | 2023-02-28 21:34:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 21:34:36 +0100 |
commit | 567afbfc1b2e7d365bc155c7c01bc84031e6eab0 (patch) | |
tree | 7d94f09b6299620c822af2776948114033432726 /app/src/main/java/com/xc3fff0e/xmanager/xManager.java | |
parent | Update build.gradle (diff) | |
download | xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.tar xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.tar.gz xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.tar.bz2 xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.tar.lz xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.tar.xz xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.tar.zst xManager-567afbfc1b2e7d365bc155c7c01bc84031e6eab0.zip |
Diffstat (limited to 'app/src/main/java/com/xc3fff0e/xmanager/xManager.java')
-rw-r--r-- | app/src/main/java/com/xc3fff0e/xmanager/xManager.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/app/src/main/java/com/xc3fff0e/xmanager/xManager.java b/app/src/main/java/com/xc3fff0e/xmanager/xManager.java new file mode 100644 index 0000000..7ed1e4b --- /dev/null +++ b/app/src/main/java/com/xc3fff0e/xmanager/xManager.java @@ -0,0 +1,54 @@ +package com.xc3fff0e.xmanager; + +import android.app.AlarmManager; +import android.app.Application; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.os.Process; +import android.util.Log; + +public class xManager extends Application { + + private static Context mApplicationContext; + private Thread.UncaughtExceptionHandler uncaughtExceptionHandler; + + public static Context getContext() { + return mApplicationContext; + } + + @Override + public void onCreate() { + mApplicationContext = getApplicationContext(); + this.uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); + + Thread.setDefaultUncaughtExceptionHandler( + new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread thread, Throwable throwable) { + Intent intent = new Intent(getApplicationContext(), DebugActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + intent.putExtra("error", Log.getStackTraceString(throwable)); + + PendingIntent pendingIntent = + PendingIntent.getActivity( + getApplicationContext(), + 11111, + intent, + PendingIntent.FLAG_ONE_SHOT + ); + + AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); + am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 1000, pendingIntent); + + xManagerLogger.broadcastLog(Log.getStackTraceString(throwable)); + Process.killProcess(Process.myPid()); + System.exit(1); + + uncaughtExceptionHandler.uncaughtException(thread, throwable); + } + }); + xManagerLogger.startLogging(); + super.onCreate(); + } +} |