Start Activity In Custom Uncaughtexceptionhandler Class Not Working Any More
I used to handle exception errors with this class and pass error as String to another activity for show , but this way not work any more , seems when kill process happened 'sag.cla
Solution 1:
try this, please add this code to start new activity
Intent startAppIntent = newIntent(this, sag.class);
startAppIntent.putExtra("error", errorReport.toString());
startAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startAppIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startAppIntent);
System.exit(1);
you can change this
to myContext
if this
doesn't work. Please let us know if this code works for you.
Solution 2:
Short Answer : Yes you can start an activity from UncaughtExceptionHandler
.
funrestartApp(context : Context) {
val intent = Intent(context, Destination::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
android.os.Process.killProcess(android.os.Process.myPid())
exitProcess(0)
}
you can also find the exit status number in this link
Post a Comment for "Start Activity In Custom Uncaughtexceptionhandler Class Not Working Any More"