I am trying to take a picture with the camera of "Nexus 5X API 26" and show it in ImageView
field, before uploading it to Firebase.
First problem is that after taking a picture, it does not show up in imageView
. I am doing the following:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, CAMERA_REQUEST_CODE);}
And then I was trying to show the picture in the same way I do for the pictures taken from Gallery:
filePath = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
The part which I do not understand is how data.getData()
works in both cases (for Gallery and for Camera)?
I guess that the uploadImage()
method, should be the same for both Gallery and Camera uploads (it works for Gallery already so...).
So the thing that I am currently missing is that I am not getting the filePath
, I guess?
Is it necessary to "temporarily save" the camera's picture in order to .getData()
? Or it can work without any kind of "saving"?
I just want the user to take a picture and it should be sent to Firebase. Not necessary for user to see it in imageView
first, just to get the uri (data) in order to upload it.