Android - The app is crashing when taking photo with custom camera app.
===

I'm trying to take a photo with a custom camera app, but unfortunately I'm getting a `NullPointerException` when `takePhoto()` method is invoked.    

The exception is thrown in the `onPictureTaken()` callback on this line:

    Uri imageUri=getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());

Here is how I set the listener:

    @Override
    public void onClick(View v) {
         camera.takePicture(null, null, this);
    }

And here's the `onPictureTaken` callback:

    @Override
    public void onPictureTaken(byte[] data, Camera camera) {
    	Uri imageUri=getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
    	try{
    		OutputStream imageOS=getContentResolver().openOutputStream(imageUri);
    		imageOS.write(data);
    		imageOS.flush();
    		imageOS.close();
    	}catch (Exception e) {
    		e.printStackTrace();
    	}
    		
    	camera.startPreview();
    }


LogCat details:

    07-31 14:05:46.409: E/AndroidRuntime(2242): java.lang.NullPointerException
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.os.Parcel.readException(Parcel.java:1328)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.content.ContentProviderProxy.insert(ContentProviderNative.java:408)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.content.ContentResolver.insert(ContentResolver.java:604)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at com.testcamera.TestCameraActivity.onPictureTaken(TestCameraActivity.java:131)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.hardware.Camera$EventHandler.handleMessage(Camera.java:571)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.os.Looper.loop(Looper.java:130)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at android.app.ActivityThread.main(ActivityThread.java:3687)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at java.lang.reflect.Method.invokeNative(Native Method)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at java.lang.reflect.Method.invoke(Method.java:507)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    07-31 14:05:46.409: E/AndroidRuntime(2242): 	at dalvik.system.NativeStart.main(Native Method)

