title: How to Start new Activity from inside Uncaught Exception Handler
body: <p>In my Android application I need to manage all the uncaught exceptions from my custom Activity class. Now I have a problem here, I unable to start a Activity from inside. There is no exceptions even though the Activity is not starting.</p>
  
  <pre><code>public class MyActivity extends Activity {
      Context context;
      Throwable throwable;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          context=getApplicationContext();
          final AlertDialog.Builder builder= new AlertDialog.Builder(this);
  
          Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
  
              @Override
              public void uncaughtException(Thread thread, Throwable ex) {
                  throwable=ex;
                  new Thread(){
                      @Override
                      public void run() {
                          Looper.prepare();
  
                          builder.setTitle("Warning...!");
                          builder.create();
                          builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
  
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                  finish();
  
                              }
                          });
                          builder.setPositiveButton("More Details", new DialogInterface.OnClickListener() {
  
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                  Intent intent= new Intent(MyActivity.this,Report.class);
                                  intent.putExtra("error", throwable);
                                  startActivity(intent);
  
                              }
                          });
                          builder.setMessage(throwable.getMessage());
                          builder.show();
                          Looper.loop();
                      }
                  }.start();  
              }
          });
      }
  }
  </code></pre>