android - WebView 不显示 KOLIBRI 登录页面
问题描述
嗨,我是 Android Studio 的新手。我正在开发一个使用 WebView 打开 http url 的应用程序。这个 http url 用于访问我正在工作的学校的学习资料。webview 在其他网站上正常工作,也可以访问我的路由器设置。我无法让它在http://192.168.100.73:8080中工作。webview 仅显示图标,但当我删除行 myWebView.setWebViewClient((new WebViewClient())); 我不想这样做。我无法在谷歌中搜索类似的问题。
我的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.gves.studentresources">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.StudentResources"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.StudentResources.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
片段布局
<WebView
android:id="@+id/webview1"
android:layout_width="409dp"
android:layout_height="729dp"
android:layout_marginStart="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
片段java类
binding = FragmentHomeBinding.inflate(inflater, container, false);
View root = binding.getRoot();
WebView myWebView = root.findViewById(R.id.webview1);
myWebView.getSettings().setJavaScriptEnabled(true);
//myWebView.setWebViewClient((new WebViewClient()));
myWebView.loadUrl("http://192.168.100.73:8080");
return root;
}
应用程序运行时的屏幕截图。webview 显示图标,但没有任何反应。 使用新的 webview 代码
删除 myWebView.setWebViewClient((new WebViewClient())); 时的屏幕截图 没有新的 webview 代码的行 代码
我正在使用 Android Studio 的默认导航抽屉模板。我希望你能帮我解决这个问题。
解决方案
我通过添加这一行来解决我的问题。
myWebView.getSettings().setDomStorageEnabled(true);
但我还有另一个问题。Webview 中的下载资源按钮丢失。bluestaks 中的 google chrome 与 android studio 模拟器相比
推荐阅读
- c - 返回函数'str'有什么问题?谁能解释在函数中传递字符串后如何返回字符串
- javascript - 过滤数组的难点理解 - Eloquent Javascript 第 5 章
- vue.js - 状态栏如何导出excel
- python - 将字符串列表添加到 input 元素下的下拉元素中,以使搜索引擎具有自动完成功能
- mysql - 请求与 MySQL 中的可选条件匹配的任何行
- c# - 我应该如何释放在 Rust 中分配的 C# byte[]?
- c - 使用 fgets() 和 gets() 字符串函数来查看它们的区别。但是,使用字符串时遇到缓冲区问题
- java - BeanShell 脚本错误:bsh.ParseException:第 126 行第 23 列的解析错误。遇到:,
- javascript - 如何找到用户发送的自定义表情符号的 ID 并将其添加到服务器?
- circleci - CircleCI 上传到 Codecov 不起作用