我必须放一个聊天URL在网络视图中打开,但它没有打开。当我将URL更改为谷歌URL时,网络视图正常工作。有人知道为什么我的URL没有打开,而其他的,比如谷歌的,却打开了吗?
我需要打开的URL是https://www10.directtalk.com.br/chat31/?idd=DDD70036929AA01535BF
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
chat_webview.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
view?.loadUrl(url)
return true
}
}
chat_webview.apply {
this.settings.loadsImagesAutomatically = true
this.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
this.settings.useWideViewPort = true
this.settings.loadWithOverviewMode = true
this.settings.javaScriptEnabled = true
}
firebaseChatURL().addOnSuccessListener {
chat_webview.loadUrl(it["link"].toString())
}
}
fun firebaseChatURL(): Task<DocumentSnapshot> =
firestore().document("Settings/chatURL").get()
chat_webview.apply {
this.settings.loadsImagesAutomatically = true
this.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
this.settings.useWideViewPort = true
this.settings.loadWithOverviewMode = true
this.settings.javaScriptEnabled = true
this.webChromeClient = WebChromeClient() // add this line
}
请先移动上面的代码块,然后覆盖URL,你还没有设置网络视图,你希望网络视图覆盖URL,这就是为什么你的URL没有加载。