2017-11-09 10 views
1

QuickMathから(アンドロイド7.1とアンドロイド5.1 & Oneplus 1とVIVO)特定のAndroidのバージョンと、デバイス上の以下のエラー・スタック

*_ android.view.WindowManager$BadTokenException: 
    at android.view.ViewRootImpl.setView (ViewRootImpl.java:679) 
    at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:342) 
    at android.view.WindowManagerImpl.addView (WindowManagerImpl.java:94) 
    at android.app.Dialog.show (Dialog.java:329) 
    at com.yathirajjp.brainstimuli.QuickMath.showCustomDialog (QuickMath.java:193) 
    at com.yathirajjp.brainstimuli.QuickMath$3.onFinish (QuickMath.java:252) 
    at android.os.CountDownTimer$1.handleMessage (CountDownTimer.java:127) 
    at android.os.Handler.dispatchMessage (Handler.java:102) 
    at android.os.Looper.loop (Looper.java:154) 
    at android.app.ActivityThread.main (ActivityThread.java:6186) 
    at java.lang.reflect.Method.invoke (Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:889) 
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:779) _* 

コードスニペットと私のアプリケーションがクラッシュ.javaは次のようになります。

final Dialog customDialog = new Dialog(**this**); 
customDialog.setContentView(R.layout.custom_dialog_layout); 

waitTimer.cancel(); // Cancelling the CountDownTimer before calling the show custom dialog 

customDialog.show(); 

私はcustomDialogの初期化が疑わしいです。私は文脈を「this」として使用していますか?

+0

を行います。そうでない場合、期待どおりに動作するはずです。 –

+1

ありがとう@TrickySolutions。できます。 –

答えて

0

android.view.WindowManager $ BadTokenException:

代わりthisYourActivity.thisを呼び出す必要があります。

ない

final Dialog customDialog = new Dialog(this); 

カチッリスナーにダイアログを表示している場合、あなたは `YourActivity.this`を使用する必要が

final Dialog customDialog = new Dialog(QuickMath.this); 
+1

ありがとうAmiya。できます。 –

+1

応答が遅れていることを心よりお詫び申し上げます。私はまだオーバーフローをスタックするために非常に新しいです。私はティック・シング・マークがどこにあるのか分からなかった。 :)。 –

+0

提案された変更を加えた後、新しいデバイスで同じ問題が再度報告されました。助けてください? –

関連する問題