我正在使用此代码来显示进度条,同时要求将URL加载到WebView中,但是从Webview页开始几秒钟后,应用程序崩溃了,并且出现了错误:
java.lang.IllegalArgumentException:指定为非null的参数是 null:方法kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, 参数收藏夹
val progressBar = findViewById<ProgressBar>(R.id.prg)
val url: String = intent.getStringExtra("targetURL") ?: ""
webView.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
super.onPageStarted(view, url, favicon)
view.visibility =View.INVISIBLE
progressBar.visibility = View.VISIBLE
}
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
view.visibility =View.VISIBLE
progressBar.visibility = View.INVISIBLE
}
}
webView.settings.javaScriptEnabled = true
val settings = webView.settings
settings.domStorageEnabled = true
webView.loadUrl(url)
答案 0 :(得分:0)
使favicon
可为空。
更改
favicon: Bitmap
收件人
favicon: Bitmap?