Check if the user when log out from facebook in android facebook sdk 4 -


my problem hav app can connects facebook using facebook sdk new version(4.0) , want when user logs facebook , textview appears , show it's name , when log out clicked textview disappears.

the first part done , can data want:

    btnloginbutton.registercallback(callbackmanager,                 new facebookcallback<loginresult>() {                     @override                     public void onsuccess(loginresult loginresult) {                         fbloginclicked = true;                         graphrequest.newmerequest(loginresult.getaccesstoken(),                             new graphrequest.graphjsonobjectcallback() {                                     @override                         public void oncompleted(jsonobject object,                                             graphresponse response) {                                         try {                                      string jsonresult = string                                                         .valueof(object);                                     string str_firstname = object    .getstring("first_name");                                                 string str_lastname = object                                                         .getstring("last_name");                                                 fullname = str_firstname + " "                                                         + str_lastname;                                              } catch (jsonexception e) {                                                  e.printstacktrace();                                             }                                             if (fullname != null) {                                                 txtfbemail                                                         .setvisibility(view.visible);                                                 txtfbemail.settext(fullname);                                             }                                          }                                     }                                  }).executeasync();                     } 

but after logout don't know how understand logout clicked , set visibility of txtfbemail gone.

i tryed code on oncreate() when restart app partly useful , when log out clicks can not give order disappear textview.:

accesstoken fb_token = accesstoken.getcurrentaccesstoken();      if(fb_token == null) {          txtfbemail.setvisibility(view.gone);      } 

this method ever want exact time logout clicked:

accesstokentracker = new accesstokentracker() {          @override          protected void oncurrentaccesstokenchanged(accesstoken oldaccesstoken,                                                     accesstoken currentaccesstoken) {                  if (currentaccesstoken == null) {                      //write code here when user clicks on facebook logout                      checkloggedinprofile();                  }           }     }; 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -