java - Name and profile picture from Facebook into Android app -
i'm having problems displaying facebook picture , name. can't figure out right way it. login button facebook works fine.
i got error: profilepictureview.setprofileid(profile.getid()); error null
public class profile extends activity { /** * called when activity first created. */ webview web; arraylist<navigationdraweritem> listitems; drawerlayout drawerlayout; actionbardrawertoggle drawertoggle; listview list; private callbackmanager callbackmanager; private profilepictureview profilepictureview; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); facebooksdk.sdkinitialize(getapplicationcontext()); setcontentview(r.layout.activity_profile); callbackmanager = callbackmanager.factory.create(); loginbutton loginbutton = (loginbutton) findviewbyid(r.id.login_button); loginbutton.setreadpermissions("public_profile", "email", "user_friends"); final profilepictureview profilepictureview = (profilepictureview) findviewbyid(r.id.profilepic); loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { accesstoken accesstoken = loginresult.getaccesstoken(); com.facebook.profile profile = com.facebook.profile.getcurrentprofile(); profilepictureview.setprofileid(profile.getid()); intent = new intent(profile.this, profile.class); startactivity(i); system.out.print("logged in"); } public final void getprofileid(){ log.i("profileid", "your profileid"); } public final void setprofileid(string profileid) { log.i("profileid", "your profileid"); } @override public void oncancel() { // app code } @override public void onerror(facebookexception exception) { // app code log.i("error", "error"); } });
my xml file shows no user image. not mine.
<com.facebook.login.widget.profilepictureview android:id="@+id/welcome_profile_pic" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" android:gravity="center_horizontal" facebook:preset_size="small" />
first me tells me might missing
@override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); }
Comments
Post a Comment