CsharpBeginner
CsharpBeginner

Reputation: 1773

webview browser not loading

I created a web view and im trying to just launch google.com for now. Everything compiles right but when it opens it shows the default web page that says "Webpage not avaialable" The webpage at http://www.google.com might be temporarly down or it may have moved permantly to a new web address.

What am i missing to get this to open the web page? I tested it in the enumerator and on my phone. Both have web acess i can open google just fine from a browser on my phone.

Below is my webview.jave webview Manifest and Main.xml

package com.webview;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

public class WebViewActivity extends Activity { 

WebView mWebView; 

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    final Activity mActivity = this; 
    super.onCreate(savedInstanceState); 

    this.getWindow().requestFeature(Window.FEATURE_PROGRESS); 
    setContentView(R.layout.main); 

    // Makes Progress bar Visible 
    getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); 

    mWebView = (WebView) findViewById( R.id.webview ); 
    mWebView.getSettings().setJavaScriptEnabled(true);      
    mWebView.loadUrl("http://www.google.com"); 

    mWebView.setWebChromeClient(new WebChromeClient()  
    { 
        public void onProgressChanged(WebView view, int progress)   
        { 
            //Make the bar disappear after URL is loaded, and changes string to Loading... 
            mActivity .setTitle("Loading..."); 
            mActivity .setProgress(progress * 100); //Make the bar disappear after URL is loaded 

        } 
    }); 
} 
} 

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.webview" 
android:versionCode="1" 
android:versionName="1.0"> 
<uses-sdk android:minSdkVersion="10" /> 

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <activity android:name=".WebViewActivity" 
        android:label="@string/app_name"> 
    <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 
        <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

</application> 

Main.xml

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

<WebView   
    android:id="@+id/webview"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
/>  

<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello"
/>
</LinearLayout>

Upvotes: 0

Views: 478

Answers (1)

Sunny
Sunny

Reputation: 14838

You need an internet Permission in your manifest file.

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

Upvotes: 1

Related Questions