所以我有一个移动版网站.我正在尝试为它做一个应用程序.
这是我的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"/>
Run Code Online (Sandbox Code Playgroud)
这是我的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"); }}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当我运行应用程序时,它在我的手机上说(我在手机上运行APP作为模拟器)我收到此错误
网页无法显示
无法加载http://esouqbh.com上的网页:
网:: ERR_CACHE_MISS
请注意,如果我从计算机浏览器或手机打开它,我的网站运行正常,没有任何问题.
通过添加编辑::找到解决方案
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Run Code Online (Sandbox Code Playgroud)
在androidmanifest.xml中!
不,它不是一个文件夹,添加:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Run Code Online (Sandbox Code Playgroud)
进入你的AndroidManifest.xml意思是你的应用程序会将页面从互联网加载到你的WebView
INTERNET权限:允许应用程序打开网络套接字.
| 归档时间: |
|
| 查看次数: |
1097 次 |
| 最近记录: |