我试图用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);
}
}
}
我已经检查了newPicPath,路径没问题,但我得到了这个异常......消息不是很明确......有什么想法吗?
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)
答案 0 :(得分:1)
我只是删除了
toBytes()
并完成了!
没什么大不了的! 我更喜欢为那些有问题而不是删帖的人发帖回答!