android - Login using Facebook login button and start a new activity -
i want start new activity after facebook login. want application have facebook login button , after login enter in other activity, in tutorial after click on login button logout button appears , don't want logout button appear. code. using facebook-android-sdk 4.1.2 test new activity class.i want open after facebook login.
textview info; private loginbutton loginbutton; private callbackmanager callbackmanager; string name; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); facebooksdk.sdkinitialize(getapplicationcontext()); callbackmanager = callbackmanager.factory.create(); setcontentview(r.layout.fb_button); info = (textview)findviewbyid(r.id.info); loginbutton = (loginbutton)findviewbyid(r.id.login_button); loginbutton.setreadpermissions(arrays.aslist("public_profile, email, user_birthday, user_friends")); loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { graphrequest request = graphrequest.newmerequest( loginresult.getaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void oncompleted( jsonobject object, graphresponse response) { // application code try { // url image_value = new url("http://graph.facebook.com/"+id+"/picture" ); name = object.getstring("email"); } catch (jsonexception e) { e.printstacktrace(); } // getting email of use info.settext(name); log.v("loginactivity", response.tostring()); } }); bundle parameters = new bundle(); parameters.putstring("fields", "id,name,email,gender, birthday"); request.setparameters(parameters); request.executeasync(); intent intent = new intent(fbactivity.this, test.class); fbactivity.this.startactivity(intent); } @override public void oncancel() { info.settext("login attempt canceled."); } @override public void onerror(facebookexception e) { info.settext("login attempt failed."); } }); // execute downloadjson asynctask } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { callbackmanager.onactivityresult(requestcode, resultcode, data); intent intent = new intent(fbactivity.this, test.class); fbactivity.this.startactivity(intent); }
you have add line code after login.
loginbutton.setvisibility(view.invisible);
remember after logout show button with
loginbutton.setvisibility(view.visible);
Comments
Post a Comment