1

I'm trying to display a local pic with Glide:

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    final ImageView imageView = (ImageView) findViewById(R.id.backdrop);
    if (resultCode == RESULT_OK) {
        if (intent != null) {
            String picName = RutaActivity.getPicName(MyApplication.TAKE_PDV_PIC);
            String newPicPath = ImageUtils.saveLargePic((Activity) ctx, picName);
            Log.e("pic", newPicPath);
            Glide.with(ctx)
                    .load(newPicPath)
                    .asBitmap()
                    .toBytes()
                    .centerCrop()
                    .into(imageView);
        }
    }
}

I have checked the newPicPath, and path is OK but I got this exception... Message is not very explicit...Any idea?

 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10, result=-1, data=Intent { act=inline-data dat=content://media/external/images/media/206 (has extras) }} to activity {com.myapp.mobile/com.myapp.mobile.AddActivity}: java.lang.IllegalArgumentException: Unhandled class: class [B, try .as*(Class).transcode(ResourceTranscoder)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3187)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3230)
        at android.app.ActivityThread.access$1200(ActivityThread.java:134)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1266)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4867)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.IllegalArgumentException: Unhandled class: class [B, try .as*(Class).transcode(ResourceTranscoder)
        at com.bumptech.glide.request.target.ImageViewTargetFactory.buildTarget(ImageViewTargetFactory.java:24)
        at com.bumptech.glide.Glide.buildImageViewTarget(Glide.java:297)
        at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:697)
        at com.bumptech.glide.BitmapRequestBuilder.into(BitmapRequestBuilder.java:498)
        at com.myapp.mobile.AddActivity.onActivityResult(AddActivity.java:134)
        at android.app.Activity.dispatchActivityResult(Activity.java:5231)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3183)

1 Answer 1

1

I've just delete

toBytes()

and done!

No big deal! I prefer posting answer for those who will have the problem rather that delete post!

Sign up to request clarification or add additional context in comments.

3 Comments

The toBytes() call indicates you want Glide to take the decoded type (Bitmap in this case because of the asBitmap() call) and transform it into byte[] before displaying it. However, Glide doesn't support displaying byte[] in ImageViews. If you remove the toBytes() call, then you're just loading a Bitmap, which Glide can display in an ImageView.
Tx for the explanation!
I need to use toBytes in order to convert it to a jpeg type like toBytes(CompressFormat.JPEG, 80) but I'm getting the same exception. Any one knows how to solve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.