2012-12-01 101 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无关。 –

相关问题