How to add a logout callback for facebook sdk in android -


i have integrated facebook sdk in android app. described in manual added login callback facebook. have change ui if user logs out facebook. put code. code login

         /**          * login callback facebook login          */         callbackmanager = callbackmanager.factory.create();      loginmanager.getinstance().registercallback(callbackmanager,             new facebookcallback<loginresult>() {                  @override                 public void onsuccess(loginresult loginresult) {                     //call updateui()                      setdata("provider","facebook");                     logintype = logintypes.fb_login;                     isloggedin = true;                     graphrequest request = graphrequest.newmerequest(                             loginresult.getaccesstoken(),                             new graphrequest.graphjsonobjectcallback() {                                 @override                                 public void oncompleted(                                         jsonobject object,                                         graphresponse response) {                                     // application code                                      txtname.settext(response.tostring());                                     updateui();                                 }                             });                     bundle parameters = new bundle();                     parameters.putstring("fields", "id,name,email");                     request.setparameters(parameters);                     request.executeasync();                 }                  @override                 public void oncancel() {                     edittext_message.settext("login cancelled.");                     // app code                 }                  @override                 public void onerror(facebookexception exception) {                     // app code                 }             }); 

there 2 possible ways:

1) need overwrite in on create accesstokentracker this:

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

2) can call loginmanager.logout() log out user

hope :)


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -