WebView错误。制作一个Android应用程序来查看我的网站

时间:2014-10-15 21:58:53

标签: android webview

所以我有一个移动版网站。我正在尝试为它做一个应用程序。

这是我的activity_main.xml文件

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/webview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scrollbars="none"/>

这是我的MainActivity.java类

package com.example.esouqbh.esouq;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.example.esouqbh.esouq.R;

public class MainActivity extends Activity
{@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove title bar as we already have it in the web app
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Point to the content view defined in XML
setContentView(R.layout.activity_main);
//Configure the webview setup in the xml layout
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
//Yes, we want javascript, pls.
webSettings.setJavaScriptEnabled(true);
//Make sure links in the webview is handled by the webview and not sent to a full browser
myWebView.setWebViewClient(new WebViewClient());
//And let the fun begin
myWebView.loadUrl("http://esouqbh.com");    }}

由于某些原因,当我运行应用程序时,它在我的手机上显示(我在手机上运行APP作为模拟器) 我收到此错误

网页不可用

http://esouqbh.com处的网页无法加载为:

净:: ERR_CACHE_MISS

请注意,如果我从计算机浏览器或手机打开网站,我的网站功能完美无误。

编辑::添加

找到解决方案
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
在androidmanifest.xml中

1 个答案:

答案 0 :(得分:5)

不,它不是文件夹,添加:

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

进入您AndroidManifest.xml意味着您的应用会将网页从互联网加载到您的WebView

INTERNET permission:允许应用程序打开网络套接字。

相关问题