I need to create a fragment that can upload images from the camera and also from the gallery to Firebase. However, when I take a picture with the camera of the device, the image is not sent to ImageView
of my fragment. Maybe it's a pretty simple mistake, but I can not solve it.
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//Se o request for da galeria
if (requestCode == REQUEST_CODE_GALLERY) {
if (resultCode == RESULT_OK) {
if (data != null) {
//envia o bm da img pro imgview
try {
imageUri = data.getData();
Bitmap bm = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), imageUri);
imgview.setImageBitmap(bm);
} catch (IOException e) {
e.printStackTrace();
}
}else{
//fala que deu erro, data = null
}
} else {
//add os alert dialog pra falar que deu erro no result code
}
}
//Se o request for da camera
if(requestCode == REQUEST_CODE_CAMERA){
if(requestCode == RESULT_OK){
if(data != null){
//comandos para mandar a foto para o imageView
Bitmap bmc = (Bitmap) data.getExtras().get("data");
imgview.setImageBitmap(bmc);
}else{
//fala que deu erro, data = null, nao ha dados
}
}else{
//add alert dialog falando que deu erro
}
}
}