Ahmed Mourad Ahmed Mourad - 5 months ago 35
Android Question

Setting a Parcelable as an ImageView image

I've been using this library https://android-arsenal.com/details/1/4072 to get images from gallary and camera to set as a profile picture.

TextView chooseImageTextView = (TextView) findViewById(R.id.signUp_uploadPicture_textView);
new View.OnClickListener() {
public void onClick(View view) {
ImagePicker.create((Activity) SignUpActivity.this)
.folderTitle("Select image folder")
.imageTitle("Select image")
.imageDirectory("Camera - Bond Messenger")

and it's been working pretty fine but the result image comes as a Parcelable ArrayList of the type Image imported from library and so comes the problem here

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_PICKER && resultCode == RESULT_OK && data != null) {

ArrayList<Image> images = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);


I get an error trying to set the result Image as in Image for the profilePictureCircleImageView

so i've tried casting it to Bitmap, BitmapDrawable and Drawable but none worked

so any help please? thank you


A quick digging into the source code of your provided library reveals that the Image class is not from the android package android.media.Image.

See Image.class from library on github

So since the class holds the path of the image you can do the following.

Bitmap bmImg = BitmapFactory.decodeFile(images.get(0).getPath());