2015-06-22 45 views
0
public void onConnected(Bundle connectionHint) { 

     String personName="Unknown"; 
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { 
     Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); 
     personName = currentPerson.getDisplayName(); 
     ......... 
    } 
} 

我已經嘗試了所有可能用戶名空

Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this); 

我加倍檢查SHA鍵和谷歌服務的密鑰生成。

但它返回空值。

+0

您是否嘗試了另一個Google帳戶來測試它? –

回答

0

嘗試這樣它會工作

private void getProfileInformation() { 
     try { 
      if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { 
       Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); 
       String personName = currentPerson.getDisplayName(); 
       String personPhotoUrl = currentPerson.getImage().getUrl(); 
       String email = Plus.AccountApi.getAccountName(mGoogleApiClient); 

       username.setText(personName); 
       emailLabel.setText(email); 

       new LoadProfileImage(image).execute(personPhotoUrl); 

       // update profile frame with new info about Google Account 
       // profile 
       updateProfile(true); 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 

link for reference

參考上面的鏈接登錄,退出,檔案信息工作的罰款。