【问题标题】:Web site is not getting loaded in the web view. Shows "Webpage not availble"网站未在 webview 中加载。显示“网页不可用”
【发布时间】:2015-09-04 09:07:15
【问题描述】:

我尝试了网络上的所有方法。但是首先出现的屏幕出现错误,然后当我们单击错误框中的链接时,它会遍历互联网但不会在 webview 中打开。我正在使用安卓工作室。我在 webview 上看到一个屏幕,显示以下几行。

"网页不可用

http://www.google.com的网页无法加载,因为:

net::ERR_CACHE_MISS"

请尽快提供帮助。

这是我的代码:

MainActivity.java

package com.example.shabeer.webrtc;


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;


   public class MainActivity extends AppCompatActivity {

   private WebView browser = (WebView) findViewById(R.id.web);
   @Override
   protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    WebSettings webSettings = browser.getSettings();
   webSettings.setJavaScriptEnabled(true);
    browser.loadUrl("http://beta.html5test.com/");

}

}

activity_main.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<WebView
    android:id="@+id/web"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</WebView>

【问题讨论】:

    标签: android webview


    【解决方案1】:

    我遇到了同样的问题,因为在我的清单文件夹中,我的 Internet 权限大写:

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


    但这听起来不像这里的情况

    点击[https://stackoverflow.com/a/25860613/2530660]

    【讨论】:

    • 我刚刚得到它。谢谢。我没有注意到它都是大写的。
    【解决方案2】:

    请检查您是否在 Manifest.xml 文件中添加了 Internet 权限

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

    【讨论】:

    • 我在 Manifest.xml 文件中添加了这行代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    • 2017-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多