1

I want to download the images from Parse cloud and load them into map icon. I am using Picasso to convert the images into bitmap. I am working with map for the first time I am not sure if my method correct to load the images into map icons. Please somebody help me!

  markerOpts =
                markerOpts.title(post.getText());
          String uri = post.getImage().getUrl();
          final MarkerOptions finalMarkerOpts = markerOpts;
          Picasso.with(context)
                  .load(uri)
                  .into(new Target() {
                    @Override
                    public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
            /* Save the bitmap or do something with it here */

                      //Set it in the ImageView
                      finalMarkerOpts.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
                    }

                    @Override
                    public void onBitmapFailed(Drawable errorDrawable) {

                    }

                    @Override
                    public void onPrepareLoad(Drawable placeHolderDrawable) {

                    }
                  });
        //  }
          // Add a new marker
          Marker marker = mapFragment.getMap().addMarker(markerOpts);
          mapMarkers.put(post.getObjectId(), marker);
        //  if (post.getObjectId().equals(selectedPostObjectId)) {
         //   marker.showInfoWindow();
           // selectedPostObjectId = null;
      //   }
        }
        // Clean up old markers.
        cleanUpMarkers(toKeep);
      }
    });
  }

Parse Model

 public ParseFile getImage(){
    return getParseFile("Image");
  }

Logcat:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.parse.ParseFile.getUrl()' on a null object reference
                                                                       at com.google.mywall.MainActivity$2.done(MainActivity.java:688)
                                                                       at com.google.mywall.MainActivity$2.done(MainActivity.java:627)
3
  • post logcat trash here. Commented Apr 9, 2016 at 12:03
  • post.getImage().getUrl(); check this and put try catch for that. Commented Apr 9, 2016 at 12:12
  • @Clara how do i create a log for parsefile? Commented Apr 9, 2016 at 12:26

1 Answer 1

1

You have not getting any values in post.getImage().getUrl(); So you are getting nullPointerException. Did you correctly parsed the setImage();

Sign up to request clarification or add additional context in comments.

2 Comments

I have added the image directly in the parse cloud
Directly set the image url to String uri, and check whether you have getting the same error again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.