2016-09-05 2 views
0

충돌이 발생하면 처음부터 응용 프로그램을 다시 시작해야합니다.
나는 응용 프로그램을 다시 시작하기 위해이 코드를 사용하고 있습니다 :커스텀 uncaughtException 핸들러에서 ACRA를 호출하려면 어떻게해야합니까?

public class MyExceptionHandler implements 
     java.lang.Thread.UncaughtExceptionHandler { 
    private final Context myContext; 
    public MyExceptionHandler(Context context) { 
     myContext = context; 
    } 
    public void uncaughtException(Thread thread, Throwable exception) { 
     StringWriter stackTrace = new StringWriter(); 
     exception.printStackTrace(new PrintWriter(stackTrace)); 
     System.err.println(stackTrace);// You can use LogCat too 
     Intent intent = new Intent(myContext, Initialsetup.class); 
     String s = stackTrace.toString(); 
     //you can use this String to know what caused the exception and in which Activity 
     intent.putExtra("uncaughtException", 
       "Exception is: " + stackTrace.toString()); 
     intent.putExtra("stacktrace", s); 
     Log.d("bugFix4","Handling crash"); 
     myContext.startActivity(intent); 
     Process.killProcess(Process.myPid()); 
     System.exit(0); 
    } 
} 

가 나는 또한 ACRA를 사용하여 전자 메일로 오류 보고서를 보내려고합니다.
사용자 정의 UncaughtExceptionHandler에서 ACRA를 호출 할 수있는 방법이 있습니까?

답변

0
ACRA.getErrorReporter().handleException(...) 
+0

언제 이렇게해야합니까? –

+0

'uncaughtException' 메소드에서. 당신이 그 과정을 죽이기 전에. – William

관련 문제