我正在尝试使用具有公共权限的图像设置 ImageView。图像从浏览器正确加载,但在我的应用程序中它不起作用:
Uri uri=Uri.parse("https://storage.googleapis.com/mybucket/filename.jpg");
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(
String id,
@Nullable ImageInfo imageInfo,
@Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " +
"Size %d x %d",
"Quality level %d, good enough: %s, full quality: %s",
imageInfo.getWidth(),
imageInfo.getHeight(),
qualityInfo.getQuality(),
qualityInfo.isOfGoodEnoughQuality(),
qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
FLog.d(TAG,"Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
FLog.e(getClass(), throwable, "Error loading %s", id);
}
};
PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
.setControllerListener(controllerListener)
.setUri(uri);
// other setters
imageView.setController(controller.build());
异常不是很清楚,我只是得到:
java.lang.RuntimeException: Unsupported uri scheme! Uri is: https://storage.googleapis.co...
at com.facebook.imagepipeline.core.ProducerSequenceFactory.getBasicDecodedImageSequence(ProducerSequenceFactory.java:176)
at com.facebook.imagepipeline.core.ProducerSequenceFactory.getDecodedImageProducerSequence(ProducerSequenceFactory.java:129)
at com.facebook.imagepipeline.core.ImagePipeline.fetchDecodedImage(ImagePipeline.java:147)
at com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder.getDataSourceForRequest(PipelineDraweeControllerBuilder.java:82)
at com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder.getDataSourceForRequest(PipelineDraweeControllerBuilder.java:31)
at com.facebook.drawee.controller.AbstractDraweeControllerBuilder$2.get(AbstractDraweeControllerBuilder.java:320)
at com.facebook.drawee.controller.AbstractDraweeControllerBuilder$2.get(AbstractDraweeControllerBuilder.java:317)
at com.facebook.drawee.backends.pipeline.PipelineDraweeController.getDataSource(PipelineDraweeController.java:96)
at com.facebook.drawee.controller.AbstractDraweeController.submitRequest(AbstractDraweeController.java:392)
at com.facebook.drawee.controller.AbstractDraweeController.onAttach(AbstractDraweeController.java:332)
at com.facebook.drawee.view.DraweeHolder.attachController(DraweeHolder.java:276)
at com.facebook.drawee.view.DraweeHolder.setController(DraweeHolder.java:222)
at com.facebook.drawee.view.DraweeView.setController(DraweeView.java:87)
我需要在 URL 中添加其他内容吗?我的印象是可以按原样访问公共文件。