private void openGallery() {
Intent pickImage = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(pickImage, REQ);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQ && resultCode == RESULT_OK){
Uri uri=data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),uri);
} catch (IOException e) {
throw new RuntimeException(e);
}
noticeImageView.setImageBitmap(bitmap);
}
I was trying to upload an image from a gallery but its showing nothing when I click on the UploadImage. As my code is not being able to fetch the Gallery from my desktop.