I’m trying to update a imageView in my activity,the user clicks on the Imageview, Onclick of Imageview I am opening gallery to choose image, when user has selected the picture, it returned to the previous activity with the selected image and uptate imageview.
But I am not able to update my imageview.
Can you suggest me where I am lacking, below is my code.
if(requestCode == Activity.RESULT_OK){
Uri selectedpic = pic.getData();
try{
Bitmap bmpic = MediaStore.Images.Media.getBitmap(
this.getContentResolver()
, selectedpic);
((BitmapDrawable)spic.getDrawable()).getBitmap().recycle();
spic.setImageBitmap(bmpic);
spic.invalidate();
}catch(FileNotFoundException e){
Log.e(this.getClass().toString(), e.getMessage());
} catch (IOException e) {
Log.e(this.getClass().toString(), e.getMessage());
}
}
this line of code was wrong:
it has to be: