How to detect logout event with the Facebook Android API v4?

You can try this also

 if(AccessToken.getCurrentAccessToken()!=null)
 {
   Log.v("User is login","YES");

 }
else
{
         Log.v("User is not login","OK");
      LoginManager.getInstance().logInWithReadPermissions(WelcomeActivity1.this, (Arrays.asList("public_profile", "user_friends","user_birthday","user_about_me","email")));
 }

You can set a listener on the onCreate() method on your activity

AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken,
                AccessToken currentAccessToken) {

            if (currentAccessToken == null){
                //User logged out
            }
        }
    };

You need to import com.facebook.AccessToken and com.facebook.AccessTokenTracker

When you create the instance of AccessTokenTracker it implicitly starts tracking. For stopping tracking you should call AccessTokenTracker.stopTracking() e.g. in onDestroy() to not receive anymore events when not needed/wanted and especially to not leak memory!

You can get any time if the user is logged in/out by calling

AccessToken at = AccessToken.getCurrentAccessToken();

If the user is not logged in, you get a null value.

For further reference please check the documentation at https://developers.facebook.com/docs/reference/android/current/class/AccessTokenTracker/