我必须从Facebook的图形api中检索图像路径。我如何将它存储到我的区域存储中?当我在一个完整的方法上使用语言环境存储时,我得到一个null来存储在本地存储上。无法存储来自Facebook API的数据
private void getPhotoFromId(String photoId) {
Log.d("Adapter" + "getPhotoFromId:-", photoId + "");
GraphRequest request = GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken(), "/" + photoId, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
Log.d("Adapter Photo", response.toString());
try {
JSONObject mObject = new JSONObject(String.valueOf(response.getJSONObject()));
JSONArray mArray = mObject.getJSONArray("images");
JSONObject imageObject = mArray.getJSONObject(0);
source = imageObject.getString("source");
prefHelper.savePref(Constants.IMAGE_SOURCE,source);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "images,picture");
request.setParameters(parameters);
request.executeAsync();
}
你在哪里得到空异常 – Mohit
感谢您的快速回复我不会得到一个null异常值我在碎片prefrence(prefHelper),这将不可访问这个完整的方法外。 –
必须初始化它吗? – Mohit