I try to capture image from android and upload to server , I did all the code runtime permissions, uploading to server and all. but my bitmap from camera intent is null.I tries getExtras and all way. For me the code seems to be correct but bitmap is always null. What could be the reason
Tried of using
data.getExtras().get("data");
as here onActivityResult returned from a camera, Intent null
but didn't help
My code to perform camera intent on a button click
CaptureImageFromCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
intent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 7);
}
});
// Star activity for result method to Set captured image on image view
after click.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 7 && resultCode == RESULT_OK && data != null &&
data.getData() != null) {
Uri uri = data.getData();
// Adding captured image in bitmap.
// if(data.getData()==null){
bitmap = (Bitmap)data.getExtras().get("data");
//}//else{
// bitmap =
MediaStore.Images.Media.getBitmap(this.getContentResolver(), data.getData());
//}
// bitmap =
MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
// adding captured image in imageview.
ImageViewHolder.setImageBitmap(bitmap);
}
}
i want to get bitmap from camera intent and show in imageview.