简体   繁体   English

当我在物理设备上运行应用程序时,WebView 没有出现

[英]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.我正在尝试使用WebView制作 url 以在 Android Studio 中的我的应用程序中工作。 The link is basically having a .js extension so, I have provided the following code in my MainActivity.kt file.该链接基本上具有.js扩展名,因此,我在MainActivity.kt文件中提供了以下代码。

        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.我还在我的AndroidManifest.xml文件中输入了以下代码,以便访问互联网。

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

Still the WebView isn't working as it shall. WebView仍然无法正常工作。 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单击此处查看我的 XML 代码和设计片段中的 WebView 代码

You have to enable javascript like this:您必须像这样启用javascript

 myWebView.settings.javaScriptEnabled = true

Try this:尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法通过隧道在物理设备上运行我的本机应用程序 - Can't run my react native app on physical device by tunnel 在eclipse中调试时,App不会出现在物理设备中 - App won't show up in physical device when debugging in eclipse 如何在IONIC 3物理设备上运行我的应用 - How to run my app on an IONIC 3 physical device 将 Flutter 应用程序连接到 Firebase 后,我无法在物理设备上启动应用程序 - I can't launch app on my physical device after connecting my Flutter app to Firebase 为什么我的应用程序图标没有显示在模拟器或设备上? - Why isn't my app icon showing up in the emulator or on a device? 我可以在物理 android 设备 5.1 棒棒糖上运行我的 flutter 应用程序吗 - Can I run my flutter app on a physical android device 5.1 lollipop Flutter 新应用在选择 Android 物理设备时无法运行 - Flutter new app can't run when choose Android physical device Android 自动应用程序未显示在物理设备上 - Android Auto app doesn't show up on physical device 如何在Windows上的物理设备(Wiko手机)上运行离子应用程序? - How can I run my ionic app on a physical device (Wiko phone) on Windows? 如何在 Android Studio 中将我的物理设备作为模拟器运行? - How can I run my physical device as an emulator in Android studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM