2016-03-22 15 views
0

我使用Facebook LoginButton來識別我的用戶。一旦他們登錄,該按鈕將變成一個logout按鈕。刪除選項取消Facebook登出

問題出在這裏。我想對從用戶註銷的完整做出反應。但是,當點擊註銷按鈕時,將出現一個確認彈出框,其中包含選項Confirm(註銷)或Cancel。所以我不能假設點擊logout按鈕意味着用戶註銷。

有沒有辦法我沒有看到刪除該確認彈出窗口,只是做註銷?

回答

0

我不知道如何刪除確認彈出窗口。 但是,我將以下條件放入onSuccess()以分隔登錄和註銷。

boolean loggedIn = AccessToken.getCurrentAccessToken() != null; 
    Profile profile = Profile.getCurrentProfile(); 

    if(loggedIn && (profile != null)){ 
     // Login 
     profilePicture.setProfileId(profile.getId()); 
     userName.setText(profile.getName()); 
     postPictureButton.setEnabled(true); 
    } 
    else 
    { 
     // Logout 
     profilePicture.setProfileId(null); 
     userName.setText(null); 
     postPictureButton.setEnabled(false); 
    } 
+0

它沒有工作,因爲註銷不會調用「onSuccess」回調(至少在我的版本上)。我不得不使用[accessTokenTracker](http://stackoverflow.com/questions/30233284/how-to-add-a-logout-callback-for-facebook-sdk-in-android)。 – Esardes

+0

在我的應用程序調用「onSuccess」,所以應該有差異。謝謝你分享你的發現。 –