I'm trying to apply the user's Facebook profile pic as the 'icon' property in a Marker. But for some unknown reason, I'm receiving a Nullpointer exception when doing so.
The syntax is correct, I just cut off some code just to show you the only bit that's affecting it (involved with the marker).
AccessToken accessToken = AccessToken.getCurrentAccessToken();
MarkerOptions marker = new MarkerOptions().position(
new LatLng(point.latitude, point.longitude)).title("New Marker");
globalMap.addMarker(marker
.position(point)
.icon(BitmapDescriptorFactory.fromBitmap(getFacebookProfilePicture(accessToken.getUserId())))
.anchor(0.5f, 1));
}
});
}
public static Bitmap getFacebookProfilePicture(String userID){
Bitmap bitmap = null;
try {
URL imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream());
}catch(Exception e){
}
return bitmap;
}
I think it's this line that's giving me the problem but...
icon(BitmapDescriptorFactory.fromBitmap(getFacebookProfilePicture(accessToken.getUserId())))
...this is what the logcat is saying:
java.lang.NullPointerException
at maps.f.g.a(Unknown Source)
at maps.ag.g$a.<init>(Unknown Source)
at maps.ag.g.a(Unknown Source)
at maps.ag.R.<init>(Unknown Source)
at maps.ag.t.a(Unknown Source)