How my app can know when user logout from its Android native Facebook app?

后端 未结 3 1308
名媛妹妹
名媛妹妹 2021-01-06 11:53

How my app can know when user logout from its native Facebook app ?

I am using below code for Logging out from Facebook in my app. And it is working fine.

         


        
3条回答
  •  礼貌的吻别
    2021-01-06 12:45

    on destroy you clear the session and token information so that if you logout from your native application .. it will clear its credentials

    use this

      @Override 
      protected void onDestroy() {
    
       // TODO Auto-generated method stub
      super.onDestroy();
     Session session = Session.getActiveSession();
     session.closeAndClearTokenInformation();
    
    
      }
    

    OR

       public void logoutFromFacebook() {
       mAsyncRunner.logout(this, new RequestListener() {
        @Override
        public void onComplete(String response, Object state) {
            Log.d("Logout from Facebook", response);
            if (Boolean.parseBoolean(response) == true) {
                // User successfully Logged out
            }
        }
    
        @Override
        public void onIOException(IOException e, Object state) {
        }
    
        @Override
        public void onFileNotFoundException(FileNotFoundException e,
                Object state) {
        }
    
        @Override
        public void onMalformedURLException(MalformedURLException e,
                Object state) {
        }
    
        @Override
        public void onFacebookError(FacebookError e, Object state) {
        }
    });
    }
    

    try this it works for me .. so it will also resolve your issue also

提交回复
热议问题