Android经典Exception汇总
Posted 南飞的孤雁
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android经典Exception汇总相关的知识,希望对你有一定的参考价值。
1,android.view.WindowManager$BadTokenException: Unable to add window — token android.os.BinderProxy@447a6748 is not valid; is your activity running?
1.1 exception详情:
android.view.WindowManager$BadTokenException: Unable to add window — token android.os.BinderProxy@447a6748 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:468)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:239)
at android.app.Activity.showDialog(Activity.java:2488)
…
at android.os.Handler.dispatchMessage(Handler.java:99)
…
1.2 exception分析:
此Exception通常出现的场景是:在子线程中通过handler回到主线程执行Dialog.show()的时候,dialog所属的Activity正在finish过程中
1.3 exception解决:
显示dialog的时候判断activity的finish状态
if (!activity.isFinishing())
dialog.show();
1.4 参考:
http://dimitar.me/android-displaying-dialogs-from-background-threads/
2,Gradle sync failed: ‘xxxx’ already disposed
2.1 解决方案:
./gradlew clean
Restart Android stduio
以上是关于Android经典Exception汇总的主要内容,如果未能解决你的问题,请参考以下文章