title: Restart Android Application after crash
body: <p>i want to restart my Android Application after a crash. My Problem is that it also restarts when i want to close the application manually by calling the method: finish();</p>
  
  <pre><code>PendingIntent _pendingInt;
  
   @Override
  public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
      setContentView(R.layout.readings_main);
  
  //create pending intent, which starts the Application
      this._pendingInt=PendingIntent.getActivity(MyApplication.getInstance().getBaseContext(), 0,
              new Intent(getIntent()), getIntent().getFlags());
      // start handler which starts pending-intent after Application-Crash
      Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this._pendingInt, this.getApplicationContext()));
  }
  </code></pre>
  
  <p>And my CustomExceptionHandler:</p>
  
  <pre><code>public class CustomExceptionHandler implements UncaughtExceptionHandler {
  
  private PendingIntent _penIntent;
  Context cont;
  
  /**
   * Constructor
   * @param intent
   * @param cont
   */
  public CustomExceptionHandler(PendingIntent intent, Context cont) {
      this._penIntent = intent;
      this.cont=cont;
  }
  
  public void uncaughtException(Thread t, Throwable e) {
      AlarmManager mgr = (AlarmManager) cont.getSystemService(Context.ALARM_SERVICE);
      mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 60000, this._penIntent);
      System.exit(2);
  }
  }
  </code></pre>
  
  <p>So, when i call through Menu-Option finish(), the Application starts after 1 min.</p>