【发布时间】:2016-06-25 04:58:10
【问题描述】:
我正在尝试将用户的 Facebook 个人资料图片应用为标记中的“图标”属性。但由于某些未知原因,我在执行此操作时收到了 Nullpointer 异常。
语法是正确的,我只是剪掉了一些代码,只是为了向您展示影响它的唯一一点(与标记有关)。
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;
}
我认为是这条线给我带来了问题,但是......
icon(BitmapDescriptorFactory.fromBitmap(getFacebookProfilePicture(accessToken.getUserId())))
...这就是 logcat 的意思:
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)
【问题讨论】:
标签: android facebook google-maps