Android: Picasso Load Image Failed . How to Show Error Message

Android: Picasso load image failed . how to show error message

Use builder:

    Picasso.Builder builder = new Picasso.Builder(this);
builder.listener(new Picasso.Listener()
{
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception)
{
exception.printStackTrace();
}
});
builder.build().load(URL).into(imageView);

Edit

For version 2.71828 they have added the exception to the onError callback:

        Picasso.get()
.load("yoururlhere")
.into(imageView, new Callback() {
@Override
public void onSuccess() {
}

@Override
public void onError(Exception e) {
}
})

Picasso Library, Android: Using Error Listener

Picasso 2.0 allows you to attach a callback into a request.

https://github.com/square/picasso

The callback you are using is for "global" listener and it helps you debug errors that potentially happen due to a network load.

Use load(url).into(view, new Callback() {...}); in Picasso 2.0.

Remember to invoke cancelRequest(target) if you are using a Callback.

Picasso fails to load an image but provides no error message?

This issue was solved by switching from Picasso to Glide. Worked on all of my test devices. I know my original question was relatively generic, but if you're encountering the same thing (picasso won't load your image and won't print an error) see if using a different library will help. Glide is very similar.

First time error loading picture with Picasso

The problem was solved in the Picasso 2.3.0.

The fix is in the Picasso changelog:

Requests will now be automatically replayed if they failed due to network errors.

I hope this save you many hours.



Related Topics



Leave a reply



Submit