gpt4 book ai didi

android - java.lang.IllegalArgumentException : Parameter specified as non-null is null for Kotlin and WebView

转载 作者:IT老高 更新时间:2023-10-28 13:46:14 31 4
gpt4 key购买 nike

我正在尝试使用自定义 HTML 字符串填充我的 WebView,并尝试在未加载时显示进度,并在完成时隐藏它。

这是我的代码:

webView.settings.javaScriptEnabled = true
webView.loadDataWithBaseURL(null, presentation.content, "text/html", "utf-8", null)

webView.webViewClient = object : WebViewClient() {

override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
super.onPageStarted(view, url, favicon)
webViewProgressBar.visibility = ProgressBar.VISIBLE
webView.visibility = View.INVISIBLE
}

override fun onPageCommitVisible(view: WebView, url: String) {
super.onPageCommitVisible(view, url)
webViewProgressBar.visibility = ProgressBar.GONE
webView.visibility = View.VISIBLE
}
}

我收到了这个错误,它没有指向我的任何代码行:

E/AndroidRuntime: FATAL EXCEPTION: main

java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter favicon
at com.hidglobal.tmt.app.mobiBadge.ui.presentation.PresentationActivity$showPresentation$1.onPageStarted(PresentationActivity.kt)
at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:215)
at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:20)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

最佳答案

我也有同样的问题。

 java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter favicon
at com.haoyong.szzc.module.share.view.activity.WebActivity$MyWebViewClient.onPageStarted(WebActivity.kt:0)
at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:495)
at com.android.org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:122)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5313)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1116)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:809)

我只是这样做:改变

override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
super.onPageStarted(view, url, favicon)
}

 override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
}

因为在 Kotlinlang 中不允许使用 null 参数。只需将位图更改为位图?然后它会很好地工作。希望这可以帮助其他人。

关于android - java.lang.IllegalArgumentException : Parameter specified as non-null is null for Kotlin and WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49323455/

31 4 0