package com.greenway.primemobile.common;
import java.io.PrintWriter;
import java.io.StringWriter;
import com.greenway.primemobile.login.LoginActivity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.widget.Toast;
public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler
{
private final Context myContext;
public ExceptionHandler(Context context) {
myContext = context;
}
public void uncaughtException(Thread thread, Throwable exception) {
StringWriter stackTrace = new StringWriter();
exception.printStackTrace(new PrintWriter(stackTrace));
System.err.println(stackTrace);
Intent intent = new Intent(myContext, ClassName.class);
myContext.startActivity(intent);
System.exit(0);
}
}
The above class get's called when force-close happens, but how can I show a dialog or toast
message to user that the application has crashed. Since its run on a different thread, I am not sure about how to add one.