//try this to pick image from gallery..
public void gotogallery(View view) {
// onclick for gallery button
chooseImage();
}
// choose image from gallery
public void chooseImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); //activity result method call
}
@Override
protected void onActivityResult(int requestcode,int resultcode,Intent data ) {
super.onActivityResult(requestcode, resultcode, data);
if (requestcode == PICK_IMAGE_REQUEST && resultcode == RESULT_OK && data != null && data.getData() != null) {
Uri uri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
slectimageview=findViewById(R.id.imageviewimagetopdf_id);
slectimageview.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}