我看到here,您可以在登录意图成功后获得用户的帐户,方法如下:
Auth.GoogleSignInApi.getSignInResultFromIntent(data).getSignInAccount();data是您在onActivityResult()中接收的数据。
API中是否有一个静态方法可以将account作为GoogleSignInResult或GoogleSignInAccount对象提供给我,以便我以后可以在代码中使用,而不一定是在获得ActivityResult时使用?
例如,在Facebook中,我想要的等价物是:
Profile.getCurrentProfile();发布于 2017-08-12 03:46:49
您可以像这样轻松地获取当前用户。
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
GoogleSignInAccount acct = opr.get().getSignInAccount();
// use acct to get all the information you want abt the user
}https://stackoverflow.com/questions/40876941
复制相似问题