我必須從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