android - Converting Facebook ProfilePictureView to bitmap to use in ImageView -
i trying convert profile image returned facebook , change bitmap can use in method requires bitmap. i'm able profile picture using code below , put profilepictureview. created 2 other views testing...a circleimageview , imageview. far profilepictureview shows image. here example of code tried, although have tried several methods i've found on web create bitmap , none have worked. suggestions/solutions appreciated!
profilepictureview profilepictureview; profilepictureview = (profilepictureview) findviewbyid(r.id.facebookpictureview); profilepictureview.setprofileid(userid); //this works , set profile pic standardimageview = (imageview) findviewbyid(r.id.imageview); circleimageview = (circleimageview) findviewbyid(r.id.profimage); asynctask<void, void, bitmap> t = new asynctask<void, void, bitmap>() { protected bitmap doinbackground(void... p) { bitmap bmp = null; try { url aurl = new url("http://graph.facebook.com/" + userid + "/picture?type=large"); urlconnection conn = aurl.openconnection(); conn.setusecaches(true); conn.connect(); inputstream = conn.getinputstream(); bufferedinputstream bis = new bufferedinputstream(is); bmp = bitmapfactory.decodestream(bis); bis.close(); is.close(); } catch (ioexception e) { e.printstacktrace(); } return bmp; } protected void onpostexecute(bitmap bmp) { standardimageview.setimagebitmap(bmp); circleimageview.setimagebitmap(bmp); } }; t.execute();
using debugger , stepping through, have found bmp null. i've tried few other methods , same thing has happened. help!
you decide use glide well, better option picasso
bitmap thebitmap = null; thebitmap = glide. with(getactivigetapplicationcontext()). load("your image url here"). asbitmap(). into(-1, -1). get();
Comments
Post a Comment