[英]Android - webView: Web page not availale
I am trying to convert a web page into an app, but it is showing web page not available despite of how many links(url) I provided... here is my .java file 我正在尝试将网页转换为应用程序,但显示的网页不可用,尽管我提供了多少链接(URL)...这是我的.java文件
package com.example.prem.webview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
WebView wb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wb = (WebView) findViewById(R.id.web);
wb.getSettings().setJavaScriptEnabled(true);
wb.loadUrl("http://www.easyolineconverter.com");
//line of code for opening links in app
wb.setWebViewClient(new WebViewClient());
}
}
here is my manifest.xml file 这是我的manifest.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.prem.webview">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Solution: 解:
Use this: 用这个:
android:usesCleartextTraffic="true"
as shown below, in your Manifest.xml 如下所示,在您的Manifest.xml中
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
....... (Write Here)
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Hopefully your problem will be solved. 希望您的问题能得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.