简体   繁体   中英

The WebView ain't showing up when I run the app in my physical device

I am trying to use WebView for making an url to work in my app in Android Studio. The link is basically having a .js extension so, I have provided the following code in my MainActivity.kt file.

        myWebView.settings.javaScriptEnabled
        myWebView.loadUrl("https://wordsmith.org/words/quote.js")
        myWebView.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(
                view: WebView,
                request: WebResourceRequest
            ): Boolean {
                view.loadUrl(request.toString())
                return true
            }
        }

And I have also entered the following code into my AndroidManifest.xml file in order to give access to internet.

<uses-permission android:name="android.permission.INTERNET" />

Still the WebView isn't working as it shall. Is there something that I'm missing out or any else solutions?

Click here to check out the WebView code in my XML code and Design snippet

You have to enable javascript like this:

 myWebView.settings.javaScriptEnabled = true

Try this:

        myWebView.settings.javaScriptEnabled = true
        myWebView.settings.domStorageEnabled = true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM