Android Restarting the Application

463 Views Asked by At

I am trying to restart the app when the crash occurs in android using Thread.UncaughtExceptionHandler. Can i restart the app with current activity stack as a new process?? If yes how can i do it?

2

There are 2 best solutions below

3
On

One method is to override the onPause method in the activity to kill the app. Like this:

public class MyActivity extends Activity {
    @Override
    public void onPause() {
        finish();
    }
2
On

As far as I know, Once you kill your process, the garbage collector will run, and all objects that belongs to your app, that consumes memory will get freed, that is all objects will have null value. So starting the app with previous process' activity stack trace is not possible.