2012-12-01 102 views
-1

最終,我需要一個可以訪問應用程序管理部分的用戶ID白名單。我希望使用Facebook身份驗證和相關的用戶配置文件ID來處理這個問題。只允許特定FB用戶訪問應用程序

目前,我有:

if (session == Session.getActiveSession()) { 
    if (user != null) { 
     // Set the id for the ProfilePictureView 
     // view that in turn displays the profile picture 
     profilePictureView. setProfileId(user.getId()); 

     // Set the Textview's text to the user's name 
     userNameView.setText(user.getName()); 

     // Set the Textview's text from user's id 
     userId.setText(user.getId()); 

     String approved = "553660552"; 

     if(user.getId() != approved){ 
      //553660552 
      userId.setText(user.getId()); 
     } else { 
      userId.setText("Goodie"); 
     } 

    } 
} 

user.getId()返回553660552,又比較失敗。 (當批准的價值不同時,它也會失敗)。

總而言之,user.getId()返回553660552(在這種情況下)。我需要能夠對白名單進行匹配比較。是的,任何設置等於「553660552」的String不匹配

所有幫助表示讚賞。您的字符串進行比較即

回答

2

使用.equals()方法,

if (approved.equals(user.getId())) 
+0

感謝。我做了一些搜索尋找這個答案,但它顯然是一個基本的Java問題,並且與Android或Facebook SDK無關。 –

相關問題