Android应用无法打开某些网页?

时间:2011-10-03 15:56:50

标签: android android-webview

我的Android应用无法打开某些网页。相同的网址在常规网络浏览器中正常工作。谢谢你的建议。

Error Msg: **Web Page not available**
The web page at www.talladega.edu might be temporarily down or 

它可能已永久移动到新的网址。

**Here are some suggestions:**
 - Check signal and data connection
 - Reload this page later
 - View a cached copy of the web page from Google

请让我知道我做错了什么。谢谢你的时间!

/** Called when the activity is first created. */
**@SuppressWarnings("static-access")**
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        return;
    }
    pageLink  =  extras.getString("pageLink");
    if (pageLink != null) {
        setContentView(R.layout.displayview);
        WebView web = (WebView) findViewById(R.id.webview);         
        web.enablePlatformNotifications();
        web.getSettings().setJavaScriptEnabled(true);
        web.loadUrl(pageLink);
        web.setWebViewClient(new localWebViewClient()); 
        //web.getSettings().setUserAgentString("silly_to_do_this");  --- **do I need to set this ?**
    }
}

private class localWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;            
    }
}

=== displayview.xml ===

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent" android:background="@color/pageBackGroundColor">

    <WebView android:id="@+id/webview" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:background="@color/pageBackGroundColor"
    />
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

您的应用是否有权访问互联网?

<uses-permission android:name="android.permission.INTERNET" />
相关问题