Facebook SDK for Android: how to get the user's gender

后端 未结 3 573
无人共我
无人共我 2021-01-17 04:03

I suppose its either getProperty(\"sex\") or (\"gender\") or user.asMap().get(\"sex\") or (\"gender\") ? also, what kind

相关标签:
3条回答
  • 2021-01-17 04:09

    You can get the gender of user from the "user_about_me" permission and get the gender from the response json by user.getProperty("gender") .toString().

    0 讨论(0)
  • 2021-01-17 04:13
      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);
            }
        });
    
    0 讨论(0)
  • 2021-01-17 04:14

    no seperate permission for this this values you can get gender like this And see 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();
        }
    
    0 讨论(0)
提交回复
热议问题