2014-09-22 21 views
0
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) { 
       runOnUiThread(new Runnable() { 

        @Override 
        public void run() 
        { 

         Toast.makeText(getApplicationContext(),"LogOut Successfull", Toast.LENGTH_LONG).show(); 
        } 

       }); 

      } 
     } 

     @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) { 
     } 
    }); 
} 

登錄後,如果我點擊退出按鈕無法退出,並再按一次登錄按鈕獲取會話true.How我可以從這裏得到註銷,以便其他用戶可以登錄使用他/她的臉書ID。無法安卓的Facebook登錄後註銷

回答

1

For logut use:

import com.facebook.Session; ....

Session.getActiveSession()。closeAndClearTokenInformation();

+0

方法getActiveSession()函數是未定義的類型SpellCheckerService.Session .......表示上述錯誤 – 2014-09-22 12:22:55

+1

,您在導入正確的類? import com.facebook.Session; – 2014-09-22 12:26:20

1
import com.facebook.Session; 

    private void logout() 
    { 
     // clear any user information 
     mApp.clearUserPrefs(); 

     // find the active session which can only be facebook in my app 
     Session session = Session.getActiveSession(); 

     // run the closeAndClearTokenInformation which does the following 
     // DOCS : Closes the local in-memory Session object and clears any persistent 
     // cache related to the Session. 
     session.closeAndClearTokenInformation(); 

     // return the user to the login screen 
     startActivity(new Intent(getApplicationContext(), LoginActivity.class)); 

     // make sure the user can not access the page after he/she is logged out 
     // clear the activity stack 
     finish(); 
    } 
+0

與上一個相同的問題 – 2014-09-22 12:27:46

+0

在導入com.facebook.Session時導入com.facebook.Session類 – Sujewan 2014-09-22 12:30:56

+0

;獲取錯誤 – 2014-09-22 12:33:26