所以我有一个移动版的网站。我正在试着做一个应用程序。
这是我的activity\u 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"); }}
出于某种原因,当我运行应用程序时,它会在我的手机上显示(我在手机上作为模拟器运行该应用程序)
我知道这个错误
网页不可用
无法将位于http://esouqbh.com的网页加载为:
net::错误缓存未命中
请注意,如果我从电脑浏览器或手机上打开我的网站,它的功能将完全正常。
编辑::通过添加找到解决方案
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
在androidmanifest.xml中!
最佳答案
不,它不是一个文件夹,通过添加:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
进入您的
AndroidManifest.xml
意味着您的应用程序将从Internet将页面加载到您的WebView
INTERNET permission:允许应用程序打开网络套接字。