Why back press shows error while generating drawing graph in surface view?
<p>I'm developing an application to draw a graph by fetching camera parameters by placing finger on back CAMERA. If I press back button on the middle of the process to draw graph it shows force fully closed. Any help please..</p>

<pre><code>public void onBackPressed() {
            // TODO Auto-generated method stub
            super.onBackPressed();
            timer.cancel();
            mCamera.stopPreview();
            //Calling Home Page
            startActivity(new Intent(Graph.this,Home.class));
            mp.release();
            finish();
        }
</code></pre>

<p>Where mp and mCamera are the reference of mediaplayer and Camera respectively</p>

<p>here is my log cat</p>

<pre><code>02-20 15:47:48.179: E/AndroidRuntime(7606): FATAL EXCEPTION: main
02-20 15:47:48.179: E/AndroidRuntime(7606): java.lang.NullPointerException
02-20 15:47:48.179: E/AndroidRuntime(7606):     at com.yakshna.h2h.Home.onBackPressed(Home.java:120)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.app.Activity.onKeyUp(Activity.java:1898)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.view.KeyEvent.dispatch(KeyEvent.java:1347)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.app.Activity.dispatchKeyEvent(Activity.java:2078)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1857)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2626)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.view.ViewRoot.deliverKeyEvent(ViewRoot.java:2591)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1880)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.os.Looper.loop(Looper.java:123)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at android.app.ActivityThread.main(ActivityThread.java:3687)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at java.lang.reflect.Method.invokeNative(Native Method)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at java.lang.reflect.Method.invoke(Method.java:507)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-20 15:47:48.179: E/AndroidRuntime(7606):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Thanks 
Bamadeva</p>
