NullPointerException on Back Button Press
<p>I am in the process of updating my app and right now I am getting NullPointerException when I press the back button. Here is my main activity:</p>

<p><img src="http://www.appinfluence.com/wp-content/uploads/2011/11/screenshot1.png" alt="image">
<img src="http://www.appinfluence.com/wp-content/uploads/2011/11/screenshot2.png" alt="image2"></p>

<p>When clicking music my second activity is launched and it has a webview nested inside it. I am having issues getting the back button to work properly. I expect it to go back in the browser until getting to the first page and then back to the first activity once it can't go back anymore. Here is my code, and log file.</p>

<pre><code> @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; mWebView.canGoBack()) {
        mWebView.goBack();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}


11-03 16:41:14.386: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception     (group=0x4001d800)
11-03 16:41:14.486: E/AndroidRuntime(282): FATAL EXCEPTION: main
11-03 16:41:14.486: E/AndroidRuntime(282): java.lang.NullPointerException
11-03 16:41:14.486: E/AndroidRuntime(282):  at     com.appinfluence.musicpromotion.WebViewActivity.onKeyDown(WebViewActivity.java:315)
11-03 16:41:14.486: E/AndroidRuntime(282):  at     android.view.KeyEvent.dispatch(KeyEvent.java:1037)
11-03 16:41:14.486: E/AndroidRuntime(282):  at     android.app.Activity.dispatchKeyEvent(Activity.java:2068)
11-03 16:41:14.486: E/AndroidRuntime(282):  at     com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:16    43)
11-03 16:41:14.486: E/AndroidRuntime(282):  at    android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
11-03 16:41:14.486: E/AndroidRuntime(282):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
11-03 16:41:14.486: E/AndroidRuntime(282):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
11-03 16:41:14.486: E/AndroidRuntime(282):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-03 16:41:14.486: E/AndroidRuntime(282):  at android.os.Looper.loop(Looper.java:123)
11-03 16:41:14.486: E/AndroidRuntime(282):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-03 16:41:14.486: E/AndroidRuntime(282):  at java.lang.reflect.Method.invokeNative(Native Method)
11-03 16:41:14.486: E/AndroidRuntime(282):  at java.lang.reflect.Method.invoke(Method.java:521)
11-03 16:41:14.486: E/AndroidRuntime(282):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-03 16:41:14.486: E/AndroidRuntime(282):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-03 16:41:14.486: E/AndroidRuntime(282):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>You guys are right my webview is null, BUT WHY?</p>

<pre><code>WebView mWebView;
WebView mWebView = (WebView) findViewById(R.id.webview);
</code></pre>

<p>changed to this (OOPS!):</p>

<pre><code>WebView mWebView;
mWebView = (WebView) findViewById(R.id.webview);
</code></pre>
