7

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?

PgmFreek
  • 6,374
  • 3
  • 36
  • 47

2 Answers2

1

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();
    }
Zaid Daghestani
  • 8,555
  • 3
  • 34
  • 44
  • The above code finishes the corresponding activity rite?? I used the following code to kill the process android.os.Process.killProcess(android.os.Process.myPid()); – PgmFreek Jun 05 '12 at 05:22
  • Ah so you're trying to kill the process and start the app again right after the process is killed? – Zaid Daghestani Jun 05 '12 at 05:23
  • yes... After killing the process i used alarm manager to start the app... But my question is can i start the app with previous process's activity stack? – PgmFreek Jun 05 '12 at 05:25
0

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.

Shrikant Ballal
  • 7,067
  • 7
  • 41
  • 61