siutsin siutsin - 1 year ago 150
Android Question

How to load a Bitmap with Picasso without using an ImageView?


, I can use the following code to download image with callback

Picasso.with(activity).load(url).into(imageView, new Callback()
public void onSuccess()
// do something

public void onError() { }

Or simply get the Bitmap from this
. Is there anyway to add callback for just download the image? If possible please provide sample code, Cheers!

Answer Source

You can create a Target and then handle the Bitmap inside the Targets callback methods.

This is how:

// make sure to set Target as strong reference
private Target loadtarget;

public void loadBitmap(String url) {

    if (loadtarget == null) loadtarget = new Target() {
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            // do something with the Bitmap

        public void onBitmapFailed() {



public void handleLoadedBitmap(Bitmap b) {
    // do something here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download