I'm implementing Google Sign-in in my project, but this problem is difficult. When I'm not signed, GoogleSignIn.getLastSignedInAccount(activity)
returns null
, which is what it should do, according to Google's documentation. When I restart the app, it returns a GoogleSignInAccount
, but with all fields null
.
Google says:
For additional profile data that might be available, see GoogleSignInAccount. Note that any of the profile fields can be null, depending on which scopes you requested and what information the user's profile includes.
So I thought the problem would be the lack of requested information, but I properly previously defined them with:
GoogleSignIn.getClient(activity, GoogleSignInOptions.Builder()
.requestId()
.requestProfile()
.requestEmail()
.build()
);
Besides, all informations comes in a perfect GoogleSignInAccount
after signing up using the same client request above.
In my game, when GoogleSignIn.getLastSignedInAccount(activity) return null, I call startSigninIntent:
private void startSignInIntent() {
GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With