How can i find my current login status - facebook API android -


i using facebook login button integrate facebook login app.

  1. when press facebook login button , authenticates credentials , if done , change text log out & go inside app.

  2. now when use app , go out of app , when again come login screen. here see logout - authenticate myself before , didn't logout.

  3. so question how differentiate when logged in or session expired ?

here code using:

loginbutton authbutton;  authbutton = (loginbutton) findviewbyid(r.id.authbutton); // set permission list, don't forget add email  authbutton.setreadpermissions(arrays.aslist("basic_info", "email"));  authbutton.setsessionstatuscallback(new session.statuscallback() {          @override         public void call(session session, sessionstate state,                 exception exception) {              authbutton.setreadpermissions(arrays.aslist("basic_info",                     "email"));             system.out.println("inside call");             if (session.isopened()) {                 fbtoken = session.getaccesstoken();                                   }                              }                         }); 

.....................................

thank in advance.

regards, rakesh

you can session using session.getactivesession() , listen session change event

session session = session.getactivesession(); if (session != null && (session.isopened() || session.isclosed()) ) {     onsessionstatechange(session, session.getstate(), null); } 

and check session status:

private void onsessionstatechange(session session, sessionstate state, exception exception) {    if (state.isopened()) {        log.i("logged", "logged in...");    }else if (state.isclosed()) {        log.i("logged", "logged out...");    } } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -