2016-09-05 11 views
0

私はアプリケーションAを拡張するクラスAを持っています。私は未学習の例外を処理しています。アプリはすべての問題のアプリがフリーズに遭遇し、黒い画面が、私は多くのことを検索しましたが、すべてが事前にvain.Thanksに行ってきましたアプリケーションクラスからアプリケーションを終了

public class A extends Application { 
    @Override 
    public void onCreate() { 
    super.onCreate(); 
    final AppContext context = AppContext.getInstance(); 
    context.setContext(this); 
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { 
     @Override 
     public void uncaughtException(Thread thread, Throwable e) { 
      mContext = context.getContext(); 
      e.getCause().getMessage(); 
      AppPreference.getInstance().setCrashReason(e.getMessage()); 
      Intent intent = new Intent(); 
      intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
      startActivity (intent); 
      System.exit(1); 
     } 
    }); 
} 

をクラッシュする前に、表示されたときに今の問題があります。

答えて

0

あなたは以下の方法を使用することができます。これは私がやっているものです。このanswer

+0

に応じ

public class MyApplication extends Application { public void onCreate() { // Setup handler for uncaught exceptions. Thread.setDefaultUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException (Thread thread, Throwable e) { handleUncaughtException (thread, e); } }); } public void handleUncaughtException (Thread thread, Throwable e) { e.printStackTrace(); // not all Android versions will print the stack trace automatically Intent intent = new Intent(); ntent.setAction ("com.mydomain.SEND_LOG"); // see step 5. intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application startActivity (intent); } } 

を右now.Appは凍結を取得し、黒い画面がしばらくのApp応答していないアラートをup.Afterなります登場する。 –

+0

@ashlokマリクチェックは完全な回答のためのリンクを提供しています。 – Stanojkovic

+0

私は既に上記のリンクを参照しましたが、アプリがまだフリーズしていて、何らかのエラーが発生するとすぐに黒い画面が表示されます –

関連する問題