我的问题是,我无法通过ID下载用户个人资料照片。当我使用浏览器和此URL时,我能够获得用户个人资料图片:
http://graph.facebook.com/janno.hindrekson/picture?type=small
我可以看到这个用户个人头像:
但是当我想通过Android获取此图片时,我无法
// Execute the task
new LoadImage().execute("http://graph.facebook.com/janno.hindrekson/picture?type=small");
}
private class LoadImage extends AsyncTask<String, String, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(TESTPROFILEPICT.this);
pDialog.setMessage("Loading Image ....");
pDialog.show();
}
protected Bitmap doInBackground(String... args) {
try {
bitmap = BitmapFactory.decodeStream((InputStream) new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap image) {
if (image != null) {
fbUserAvatar.setImageBitmap(image);
pDialog.dismiss();
} else {
pDialog.dismiss();
Toast.makeText(TESTPROFILEPICT.this, "Image Does Not exist or Network Error", Toast.LENGTH_SHORT).show();
}
}
}
那么任何想法?我应该如何通过Android下载个人资料图片?
谢谢, 凯文