Facebook SDK for Android:如何获得用户的性别

时间:2013-12-17 11:06:21

标签: android facebook

我想它是getProperty("sex")("gender")user.asMap().get("sex")("gender")? 另外,我在下一行中设置了哪种权限?

authButton.setReadPermissions(Arrays.asList("basic_info", "email", "user_likes", "user_status"));

3 个答案:

答案 0 :(得分:8)

对此值不具有单独的权限,您可以获得此类性别并查看THIS

   private String UserInfoDisplay(GraphUser user) {    

        StringBuilder userInfo = new StringBuilder("");              
        String Name =  user.getName();
        String Id =   user.getId();
        String lastname =    user.getLastName();
        String firstname =  user.getFirstName();
        String getUsername =  user.getUsername();             

        String get_gender = (String) user.getProperty("gender");


        String image_url = "http://graph.facebook.com/"+user.getId()+"/picture?type=square";        

        Log.i("User information == >", Name +Id + lastname+ 
                firstname + image_url + get_gender +  getUsername + "usermail"+User_mail  );

        text.setText(Name + "  mail = " +User_mail);

        return userInfo.toString();
    }

答案 1 :(得分:2)

您可以从“user_about_me”权限获取用户的性别,并通过 user.getProperty(“gender”)从响应json获取性别.toString()

答案 2 :(得分:1)

  Request.executeMeRequestAsync (session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {


            String fbId = user.getId();
            String fbAccessToken = fbAccessToken;
            String fbName = user.getName();
            String gender = user.asMap().get("gender").toString();       

            Log.i("FB", gender);
        }
    });