1. Download our Official Android App: Forums for Android!

Apps Some of the pages can't open in WebView.

Discussion in 'Android Development' started by DTSun, Sep 27, 2011.

  1. DTSun

    DTSun Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Sep 26, 2011

    Sep 26, 2011
    2
    0
    5
    Hi, I'm new to Android and trying to open websites from a ListView.
    Some pages are working fine but some are not opened! The same url is working fine in a regular web browser.

    Error Msg: Web Page not available

    The web page at www.talladega.edu might be temporarily down or it may have moved permanently to a new web address.

    Here are some suggestions:
    1 - Check signal and data connection
    2 - Reload this page later
    3 - 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:eek:rientation="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>

    Please guide me how to make it workable or an alernate to open web-sites with out the WebView. Thanks !
     

    Advertisement

Share This Page

Loading...