I'm trying to set image taken from the camera into an ImageView. I launch the camera intent and then I got a NullPointerException in OnActivityResult an I don't understand the error.
Here, I launche the camera intent and I store the image in the gallery of the phone :
ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "New Picture"); imageUri = context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); pictureActionIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, CAMERA_REQUEST); Now, the image token by the camera is saved in the gallery of the phone (high quality). In onActivityResult, I want to put the image into a ImageView. This is my code :
else if (requestCode == CAMERA_REQUEST) { if (resultCode == RESULT_OK) { imageUri = data.getData(); try { Bitmap bitmap = Media.getBitmap(getContentResolver(), imageUri); //NullPointerException myImageView.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } I have a NullPointerException, why ? How can I resolve it please ?