Why do I get a NullPointerExeption when I pass an url to the webview?
<p>I get a <code>NullPointerException</code> when a url passed in webview in an activity (the url is passed from previous activity), but it shows <code>NullPointerException</code> when control goes on <code>webview.loadurl(url)</code>. I checked that there is a value in a passed url but I still don't know why it gives an error?</p>

<p>This is Error: </p>

<pre><code>06-07 15:13:43.689:ERROR/AndroidRuntime(1761): FATAL EXCEPTION: main 
06-07 15:13:43.689: ERROR/AndroidRuntime(1761): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shopzilla.android.common/com.shopzilla.android.product.ProductStoreActivity}: java.lang.NullPointerException 
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
 06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.os.Looper.loop(Looper.java:123)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at java.lang.reflect.Method.invokeNative(Native Method) 
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at java.lang.reflect.Method.invoke(Method.java:507)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at dalvik.system.NativeStart.main(Native Method)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761): Caused by: java.lang.NullPointerException
06-0715:13:43.689: ERROR/AndroidRuntime(1761):     at com.shopzilla.android.product.ProductStoreActivity.onCreate(ProductStoreActivity.java:40)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-07 15:13:43.689: ERROR/AndroidRuntime(1761):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
</code></pre>

<p>Code:</p>

<pre class="lang-java prettyprint-override"><code>package com.shopzilla.android.product;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;

import com.shopzilla.android.common.R;

public class ProductStoreActivity extends Activity{

  ProgressDialog dialog;
  Dialog dialog1;
  int count=0;
  Bundle bundle;
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
    dialog = ProgressDialog.show(this,"BIZRATE","Loading....");
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    setContentView(R.layout.storesitenew);
    bundle = getIntent().getExtras();
    //getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
    //Bundle bundle = getIntent().getExtras();
    WebView web = (WebView)findViewById(R.id.web_storesite);
    //MyWebViewClient web1 = new MyWebViewClient();
    //web1.shouldOverrideUrlLoading(web, ProductComparisonActivity.store_url);
    //web.getSettings().setJavaScriptEnabled(true);
    web.loadUrl(bundle.getString("url"));
    web.setWebViewClient(new MyWebViewClient());


    Button btn_back = (Button)findViewById(R.id.btn_back_bizrate);
    btn_back.setOnClickListener(new View.OnClickListener() {

      public void onClick(View arg0) {
        finish();   
      }
    });

    Button btn_globe = (Button)findViewById(R.id.btn_store_globe);
    btn_globe.setOnClickListener(new View.OnClickListener() {

      public void onClick(View arg0) {
        Intent browserIntent =  new Intent("android.intent.action.VIEW",
          Uri.parse(ProductComparisonActivity.store_url));
        startActivity(browserIntent);

      }
    });
  }


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

  @Override
  public void onPageFinished(WebView view, String url) {
    dialog.dismiss();
  }

  @Override
  public void onPageStarted(WebView view, String url, Bitmap favicon) {
    dialog.show();
  }
}
</code></pre>

<p>}</p>

<p>XML:</p>

<pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:orientation="vertical"&gt;
    &lt;LinearLayout android:layout_height="wrap_content"
        android:id="@+id/linearLayout1" android:layout_width="match_parent"
        android:background="@drawable/top_bar_bg"&gt;
        &lt;Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:background="@drawable/back_to_btn"
            android:id="@+id/btn_back_bizrate" android:layout_gravity="center"
            android:layout_marginLeft="10dip"&gt;&lt;/Button&gt;
        &lt;TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/text"
            android:text="Store Name" android:textColor="#ffffff"
            android:textSize="20dip" android:textStyle="bold"
            android:layout_marginLeft="12dip" android:layout_gravity="center"&gt;&lt;/TextView&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout android:id="@+id/linearLayout2"
        android:layout_width="fill_parent" android:layout_height="350dip"&gt;
        &lt;WebView android:layout_height="fill_parent"
            android:layout_width="fill_parent" android:id="@+id/web_storesite"&gt;&lt;/WebView&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout android:layout_height="wrap_content"
        android:id="@+id/linearLayout3" android:layout_width="match_parent"
        android:background="@drawable/tab_bar_bg"&gt;
        &lt;Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:background="@drawable/prev_icon"
            android:id="@+id/btn_store_prev" android:layout_marginLeft="60dip"
            android:layout_gravity="center"&gt;&lt;/Button&gt;
        &lt;Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/btn_store_next"
            android:background="@drawable/next_icon" android:layout_marginLeft="40dip"
            android:layout_gravity="center"&gt;&lt;/Button&gt;
        &lt;Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:background="@drawable/globe_icon"
            android:id="@+id/btn_store_globe" android:layout_marginLeft="80dip"
            android:layout_gravity="center"&gt;&lt;/Button&gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>
