在我的应用中,我具有可加载某些网页的Web视图。它在所有手机上都能正常工作,但在平板电脑上显示空白页。我不知道这是什么问题。我曾经覆盖过shouldOverride方法。但它永远无法解决问题。有人可以帮助我找到解决办法
class WebViewActivity : AppCompatActivity() {
var url_path: String? = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_web_view)
url_path = intent.extras.getString("url_path")
val webSettings = webView.getSettings()
webSettings.setJavaScriptEnabled(true)
webSettings.domStorageEnabled=true
val webViewClient = WebViewClientImpl(this)
webView.setWebViewClient(webViewClient)
webView.loadUrl(url_path)
}
inner class WebViewClientImpl(activity: WebViewActivity) :WebViewClient() {
var activity:Activity=activity
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
view?.loadUrl(request?.url.toString())
return true
}
override fun shouldOverrideUrlLoading(webView:WebView, url:String):Boolean {
webView.loadUrl(url)
return true
}
}
除了以下内容外,它在所有其他URL中均能正常工作: https://www.lenskart.com/john-jacobs-jj-e11272-c1-eyeglasses.html”