java - White question mark while trying to get user's Facebook profile picture in Android -
java - White question mark while trying to get user's Facebook profile picture in Android -
i store app-scoped-ids in database, hoping fetch profile pictures them via graph api.
this code:
string url = "https://graph.facebook.com/" + mate.getfacebookid() + "/picture?type=large"; defaulthttpclient httpclient = new defaulthttpclient(); httpget httpget = new httpget(url); httpresponse response = null; httpentity entity = null; seek { response = httpclient.execute(httpget); } grab (ioexception e) { e.printstacktrace(); } if (response != null) { entity = response.getentity(); } byte[] info = null; seek { info = entityutils.tobytearray(entity); } grab (ioexception e) { e.printstacktrace(); } bitmap bitmap = null; if (data != null) { bitmap = bitmapfactory.decodebytearray(data, 0, data.length); } homecoming bitmap; ...does not work , returns white question mark, why?
the url 'https://graph.facebook.com/800397776713349/picture?type=normal' works fine in chrome.
the semicolon on line missing:
string url = "https://graph.facebook.com/" + mate.getfacebookid() + "/picture?type=large" it looks you're using invalid facebook id. check mate.getfacebookid() returning valid id. when utilize valid id, i'm able homecoming image within asynctask:
use within main thread (oncreate, onactivitycreated, etc.):
getimage retrieve = new getimage((imageview)findviewbyid(r.id.yourimageview)); retrieve.execute(); getimage:
class getimage extends asynctask<string, void, bitmap> { private imageview view; public getimage(imageview view) { this.view = view; } @override protected bitmap doinbackground(string... params) { //your exact code goes here } @override protected void onpostexecute(bitmap b) { view.setimagebitmap(b); } } java android facebook
Comments
Post a Comment