0
I need to create an Fragment that can upload images from the camera and also from the gallery to Firebase. However, when I take an image with the camera of the device, the image is not sent to the ImageView
from my Ragment. Maybe it’s a very simple mistake, but I can’t 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
}
}
}