How to catch application “force closed” message?

Standard

The trick is make sure it doesn’t Force Close in the first place.

If you use the Thread.setDefaultUncaughtExceptionHandler() method you can catch the Exceptions that are causing your application to Force Close.

onCreate add:

Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
 @Override
 public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
 myHandaling(paramThread, paramThrowable);
 }
 });
public void myHandaling(Thread paramThread, Throwable paramThrowable){
 Log.e("Alert","Lets See if it Works !!!" +"paramThread:::" +paramThread +"paramThrowable:::" +paramThrowable);
 Toast.makeText(ForceCloseExceptionHandalingActivity.this, "Alert uncaughtException111",Toast.LENGTH_LONG).show();
 Intent in =new Intent(ForceCloseExceptionHandalingActivity.this,com.satya.ForceCloseExceptionHandaling.ForceCloseExceptionHandalingActivity.class);
 startActivity(in);
 finish();
 android.os.Process.killProcess(android.os.Process.myPid()); 
 }