Ok so this here is the intent I am sending
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name startActivityForResult(intent, REQUEST_CODE);
And then in the onActivityResult I am doing this:
protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i("Intent name:",data.toString()); if (requestCode == REQUEST_CODE){ if (resultCode == Activity.RESULT_OK){ Toast.makeText(this, "Image saved to \n" + fileUri.toString() , Toast.LENGTH_LONG).show(); Toast.makeText(this, "Result Code: " + resultCode , Toast.LENGTH_LONG).show(); //Bitmap mBitMap = BitmapFactory.decodeFile(data.getData().toString()); //imageView.setImageBitmap(mBitMap); } else if (resultCode == RESULT_CANCELED){ Toast.makeText(this, "Capture Cancelled", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Capture failed", Toast.LENGTH_LONG).show(); } } super.onActivityResult(requestCode, resultCode, data); }
The LogCat is showing a NullPointerException at the line that says Image Saved....
And also this:java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=null}
This happens whether i try to use the data
object or the fileUri
field of my class.
Why is data being returned null
?
Why is it that even though I am using a field of the class i still get the same error?