2016-06-13 28 views
0

爲Google+的說明這裏https://developers.google.com/+/mobile/android/people#retrieve_profile_information_for_a_signed_in_user使用Google+的電子郵件沒有GET_CONTACTS權限

可以使用Plus.AccountApi.getAccountName方法來獲取與所連接的帳戶相關聯的用戶的電子郵件地址。您必須在AndroidManifest.xml中聲明權限才能使用此方法。

獲取用戶的電子郵件登錄後,你必須編寫代碼

final String email = Plus.AccountApi.getAccountName(googleApiClient); 

末最重要的寫權限GET_CONTACTS您AndroidManifest文件。 但是當我在UBER應用程序上嘗試相同的場景時,我注意到他們不詢問GET_CONTACTS權限,還獲取用戶電子郵件,因爲我在UBER設置屏幕上看到它 如何在不詢問用戶GET_CONTACTS權限的情況下獲取用戶的Google+電子郵件。

回答

1

您可以使用以下code.For瞭解詳情,請參閱得到谷歌API的用戶見識:提前https://developers.google.com/identity/sign-in/android/people#before_you_begin

GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); 
GoogleSignInAccount acct = result.getSignInAccount(); 
String personName = acct.getDisplayName(); 
String personEmail = acct.getEmail(); 
String personId = acct.getId(); 
Uri personPhoto = acct.getPhotoUrl(); 
+0

我想它,我會回來給你,謝謝。 –

相關問題