毕加索:无法识别的HTTP方案请求类型 [英] Picasso: Unrecognized type of request for HTTP scheme

查看:169
本文介绍了毕加索:无法识别的HTTP方案请求类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在同步加载图像,以便在加载图像后显示通知.

I am loading images synchronously to display notification once the image is loaded.

bitmap = picasso.load(imageUrl).get();

工作正常,但今天我有一个例外:

It was working fine but today I got an exception:

Fatal Exception: java.lang.IllegalStateException: Unrecognized type of request: Request{
http://www.fulbori.com/mp/resources/image/19/17/e.jpg}
       at com.squareup.picasso.BitmapHunter$2.load(BitmapHunter.java:66)
       at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:206)
       at com.squareup.picasso.RequestCreator.get(RequestCreator.java:396)
       at com.jumbotail.app.utils.JtImageLoader.loadImageSync(JtImageLoader.java:397)
       at com.jumbotail.app.notifs.JumboGcmIntentService.readInboundIntent(JumboGcmIntentService.java:213)
       at com.jumbotail.app.notifs.JumboGcmIntentService.buildNotification(JumboGcmIntentService.java:273)
       at com.jumbotail.app.notifs.JumboGcmIntentService.onHandleIntent(JumboGcmIntentService.java:49)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:174)
       at android.os.HandlerThread.run(HandlerThread.java:60)

我知道当没有请求处理程序可以处理请求时,毕加索会抛出此错误.

I understand that this error is thrown by Picasso when no request handlers can handle the request.

现在,根据请求的Uri方案(为http)

Now, as per the Uri scheme of the request (which is http) canHandleRequest(Request data) method of NetworkRequestHandler should have returned true.

但是所有请求处理程序都返回了false,包括NetworkRequestHandler.因此, ERRORING_HANDLER 由毕加索返回,导致出现异常:IllegalStateException("Unrecognized type of request: " + request).

But all the request handlers returned false including NetworkRequestHandler. Thus, ERRORING_HANDLER was returned by Picasso resulting into the exception : IllegalStateException("Unrecognized type of request: " + request).

对此异常还有其他解释吗?

Is there any other explanation to this exception?

我还在毕加索提出了一个问题.

推荐答案

特别是我遇到了此错误,因为如错误所提到的,我获取的URL不是处理程序可以使用的有效URL.特别是,URL字符串在"http"之前有空格,例如:

In particular I had this error because the URL I was getting, as the error mentions, is not a valid URL that a handler can use. In particular, the URL string had spaces before the "http", like:

" http://example.com/image.jpg".

所以我只需要在url字符串上调用trim(),然后再将其加载到Picasso中,就可以了!

So I just had to call trim() on the url string, before loading it with Picasso, and worked great!

这篇关于毕加索:无法识别的HTTP方案请求类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆