取得個人資料資訊
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
使用者登入 Google 後,如果您使用 DEFAULT_SIGN_IN
參數或 requestProfile
方法設定 Google 登入,就可以存取使用者的個人資料基本資訊。如果您使用 requestEmail
方法設定 Google 登入,也可以取得使用者的電子郵件地址。
事前準備
使用 GoogleSignIn.getLastSignedInAccount
方法,要求目前登入使用者的個人資料資訊。
GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(getActivity());
if (acct != null) {
String personName = acct.getDisplayName();
String personGivenName = acct.getGivenName();
String personFamilyName = acct.getFamilyName();
String personEmail = acct.getEmail();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();
}
如需其他可能可用的設定檔資料,請參閱 GoogleSignInAccount
。請注意,任何個人資料欄位都可以是 null
,這取決於您要求的範圍和使用者個人資料所包含的資訊。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-31 (世界標準時間)。"],[],[]]