Why can't I retrieve FaceBook profile pic in Android? -
i trying retrieve facebook profile pic
using url
in android. not able retrieve image. have no error logs such following log. 04-05 04:14:41.005: d/skia(2987): --- skimagedecoder::factory returned null
. posting codes. please tell me step step doing wrong.
final imageview photoimageview=(imageview)findviewbyid(r.id.imageview1); asynctask<void, void, bitmap> t = new asynctask<void, void, bitmap>(){ protected bitmap doinbackground(void... p) { bitmap bm = null; try { url aurl = new url("http://graph.facebook.com/+"id"+/picture?type=small"); urlconnection conn = aurl.openconnection(); conn.setusecaches(true); conn.connect(); inputstream = conn.getinputstream(); bufferedinputstream bis = new bufferedinputstream(is); bm = bitmapfactory.decodestream(bis); bis.close(); is.close(); // photoimageview.setimagebitmap(bm); } catch (ioexception e) { e.printstacktrace(); } return bm; } protected void onpostexecute(bitmap bm){ // drawable drawable = new bitmapdrawable(getresources(), bm); photoimageview.setimagebitmap(bm); // photoimageview.setbackgrounddrawable(drawable); } }; t.execute();
try below code, working me.
try { url image_value = new url("http://graph.facebook.com/"+ user.getid()+ "/picture?type=large"); bitmap bmp = null; try { bmp = bitmapfactory.decodestream(image_value.openconnection().getinputstream()); } catch (ioexception e) { e.printstacktrace(); } profile_pic.setimagebitmap(bmp); } catch (malformedurlexception e) { e.printstacktrace(); }
Comments
Post a Comment