user2077356
user2077356

Reputation: 37

Why am I getting "WebPage not available" when running my web app?

Why is it happening?

public class MainActivity extends Activity

    {

    WebView browser;

    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.activity_main);
        //browser.getSettings().setJavaScriptEnabled(true);

        browser = (WebView)findViewById(R.id.webkit);

        browser.loadUrl("www.microsoft.com");
    }
}

But when I run the Android HTML5 app I get this screen goo.gl/uDkj1

I also tried other possibilities such as http:// in front or end the address with a slash and so on.

Upvotes: 1

Views: 8863

Answers (3)

Ljdawson
Ljdawson

Reputation: 12249

Make sure you have the Internet permission set in AndroidManifest.xml:

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

Edit:

browser.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {         
        view.loadUrl(url);
        return true;
    }
});

Upvotes: 3

Mohammad Ersan
Mohammad Ersan

Reputation: 12444

as the other answer said you must include the Internet permission, but please note that http://www.google.com differ of www.google.com so please include the protocol you are using in the URL.

Upvotes: 0

Ahmad
Ahmad

Reputation: 72653

I'm guessing that you forgot to set the internet permission:

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

Upvotes: 3

Related Questions