java - Getting Facebook Profile Picture in Android -
i building android app , have integrated facebook login form of registration , login. trying work out best way of getting users profile picture, have had allow @ developer docs - https://developers.facebook.com/docs/graph-api/reference/user/picture/, not sure how handle response, mean how image in response, sent via bitmap or url link, not quite sure.
here code docs provide getting profile picture
/* make api call */ new graphrequest( accesstoken.getcurrentaccesstoken(), "/{user-id}/picture", null, httpmethod.get, new graphrequest.callback() { public void oncompleted(graphresponse response) { /* handle result */ } } ).executeasync();
thanks help
you have perform graphrequest docs how so. use facebook's profilepictureview
in xml layout.
xml layout
<com.facebook.login.widget.profilepictureview android:id="@+id/myprofilepic" android:layout_width="48dp" android:layout_height="48dp" android:layout_margintop="16dp" android:layout_marginbottom="16dp"/>
activity/fragment code
profilepictureview profilepic = (profilepictureview) dialogview.findviewbyid(r.id.myprofilepic); graphrequestasynctask request = graphrequest.newmerequest(accesstoken.getcurrentaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void oncompleted(jsonobject user, graphresponse response) { if (user != null) { // set profile picture using facebook id profilepic.setprofileid(user.optstring("id")); } } }).executeasync();
Comments
Post a Comment