在Android fetch中集成googleplus(性别和生日)

我试图从Android中的googleplus集成获取性别和生日…但是性别为“0”请帮我这个..附加我的代码..请找下面的代码..生日显示为空…

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); mSignInButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mGoogleApiClient.connect(); } }); mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_PROFILE) .addScope(Plus.SCOPE_PLUS_LOGIN).build(); } protected void onStart() { super.onStart(); // mGoogleApiClient.connect(); } protected void onStop() { super.onStop(); if (mGoogleApiClient.isConnected()) { mGoogleApiClient.disconnect(); } } public void onConnectionFailed(ConnectionResult result) { if (!mIntentInProgress && result.hasResolution()) { try { mIntentInProgress = true; startIntentSenderForResult(result.getResolution() .getIntentSender(), RC_SIGN_IN, null, 0, 0, 0); } catch (SendIntentException e) { mIntentInProgress = false; mGoogleApiClient.connect(); } } } public void onConnected(Bundle connectionHint) { if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { Person currentPerson = Plus.PeopleApi .getCurrentPerson(mGoogleApiClient); String personName = currentPerson.getDisplayName(); try { int genderInt = currentPerson.getGender(); String gender = String.valueOf(genderInt); String birthday = currentPerson.getBirthday(); System.out.println("gender" + gender + "bod" + birthday); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } String email = Plus.AccountApi.getAccountName(mGoogleApiClient); } } @Override public void onConnectionSuspended(int cause) { mGoogleApiClient.connect(); } protected void onActivityResult(int requestCode, int responseCode, Intent intent) { if (requestCode == RC_SIGN_IN) { mIntentInProgress = false; if (!mGoogleApiClient.isConnecting()) { mGoogleApiClient.connect(); } } } @Override public void onResult(LoadPeopleResult peopleData) { // TODO Auto-generated method stub if (peopleData.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) { PersonBuffer personBuffer = peopleData.getPersonBuffer(); try { int count = personBuffer.getCount(); for (int i = 0; i < count; i++) { Log.d(TAG, "Display name: " + personBuffer.get(i).getDisplayName()); } } finally { personBuffer.close(); } } else { Log.e(TAG, "Error requesting people data: " + peopleData.getStatus()); } } } 

getGender()返回int .. 0 – 男性,1 – 女性..

参考: http : //developer.android.com/reference/com/google/android/gms/plus/model/people/Person.html#getGender()