Open jaysowen opened 5 years ago
换compile 'com.github.wendux:DSBridge-Android:3.0-SNAPSHOT'
试试?
换
compile 'com.github.wendux:DSBridge-Android:3.0-SNAPSHOT'
试试?
same issue
这个应该和应用主题相关,导致alert对话框实现不兼容,有两个方法可以参考:
same issue
The reason for this exception is that, as the exception message says, the activity has finished but you are trying to display a dialog with a context of the finished activity. Since there is no window for the dialog to display the android runtime throws this exception.
I override onJsAlert(...) in the WebChromeClient passed in and do extra check whether that the activity is finishing or not.
override fun onJsAlert(view: WebView?, url: String?, message: String?, result: JsResult?): Boolean {
// To avoid WindowManager$BadTokenException
if (this@MyWebActivity.isFinishing) {
return true
}
return super.onJsAlert(view, url, message, result)
}
使用的依赖是:implementation 'com.github.wendux:DSBridge-Android:master-SNAPSHOT'
Fatal Exception: android.view.WindowManager$BadTokenException Unable to add window -- token android.os.BinderProxy@e1d5cae is not valid; is your activity running? keyboard_arrow_up android.view.ViewRootImpl.setView (ViewRootImpl.java:798) android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:359) android.view.WindowManagerImpl.addView (WindowManagerImpl.java:93) android.app.Dialog.show (Dialog.java:357) arrow_right wendu.dsbridge.DWebView$6.onJsAlert (DWebView.java:704) xf.a (SourceFile:424) afc.run (Unknown Source:3)