捕获程序退出异常自动发送邮件
在主线程中
class MyUncaughtExceptionHandler implements UncaughtExceptionHandler{private final Context myContext;public MyUncaughtExceptionHandler(Context context){myContext=context;}@Overridepublic void uncaughtException(Thread thread, Throwable ex) {// TODO Auto-generated method stubStringWriter stackTrace=new StringWriter();ex.printStackTrace(new PrintWriter(stackTrace));System.err.println(stackTrace);//Intent sendIntent=new Intent(Intent.ACTION_SEND);sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"5782652@qq.com"});sendIntent.putExtra(Intent.EXTRA_TEXT, stackTrace.toString());sendIntent.putExtra(Intent.EXTRA_SUBJECT,"exception");sendIntent.setType("message/rfc822");myContext.startActivity(sendIntent);android.os.Process.killProcess(android.os.Process.myPid());}}?