1

In my Android APP, I have 2 screens HOME and SCOREBOARD.

HOME Screen : This screen has the button for google play sign-in.This button will show Sign-in if it is in signed-out status (or) Sign-Out if it is in signed-in status

SCOREBOARD : Here there is an option for sign-in while player checks Leaderboards / submitting the scores.

Issue: The player may sign-in in the HOME screen or the SCOREBOARD screen. If the player sign-in in the HOME screen it is remembered in the SCOREBOARD screen also. But when the player sign -in in the SCOREBOARD screen, when it return to the HOME screen the following method is called.

onSignInFailed() 

As we have already signed-in I am expecting the callback onSignInSucceeded().

If the Activity shares the sign-in happened in the Activity B (SCOREBOARD screen) with the Activity A (HOME screen) my problem is solved.

Could you please guide me to solve this ?

I am using the BaseGameActivity and GameHelper class and the below method for sign-in.

mHelper.beginUserInitiatedSignIn()
iappmaker
  • 2,945
  • 9
  • 35
  • 76

2 Answers2

2

There is a good answer related to this here:How to correctly use Google Plus Sign In with multiple activities?

In short, each activity should have an instance to a GoogleApiClient. The user still only needs to sign in once. The client is a lightweight object accessing a shared state in the Google Play Services process.

The callbacks will be fired as the activity starting to be used, but the boilerplate code should just call connect() as usual, and the client will be initialized correctly.

The user will only be prompted to sign-in if the user is not signed in at all.

Community
  • 1
  • 1
Clayton Wilkinson
  • 4,524
  • 1
  • 16
  • 25
  • The Sample CollectAllTheStars2 (https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/CollectAllTheStars2) has 2 activities, the main activity, and then one that is used to select from multiple saved games. – Clayton Wilkinson Oct 23 '14 at 15:44
0

Is SCOREBOARD's scopes a subset of HOME's scopes?

Sign-in succeeds when the user has agreed to allow access to your app with all of the scopes you are requesting. If HOME requests scopes A, B, and C, but SCOREBOARD only requests A and B, then a user that consented to HOME's auth dialog will connect fine in SCOREBOARD (they've already accepted A and B, it doesn't matter that they've accepted C). But a user that consents to SCOREBOARD's dialog will need to be re-authorized in HOME's dialog (they've already accepted A and B, but they still need to accept C).

This is a feature, not a bug. It allows you to do incremental auth. If you look at the auth dialog carefully, the second one will only include the new scopes that you're requesting. This allows you to only ask for what you need.

Hounshell
  • 5,321
  • 4
  • 34
  • 51
  • I have not explicitly using / adding any authority like A/B/C. I am simply using the BaseGameActivity and mHelper.beginUserInitiatedSignIn() in both the screens. I just noted that it sometimes work and sometimes fails – iappmaker Oct 23 '14 at 02:35