1

Without data access, my game app sometimes locks up by continually attempting to connect with google play services without eventually giving up.

The loop's error code is SIGNIN_REQURIED. The game does load, but access to playing it is blocked buy the continually restarting google play connecting attempt screen (with the swirling load icon).

Here is the code being referenced repeatedly:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQUEST_CODE_RESOLUTION://same constant as R_SIGN_IN_FAILED
           retryConnecting();
           break;
    }
}

.....

private void retryConnecting() {
    mIsInResolution = false;
    if (!mGoogleApiClient.isConnecting()) {
        mGoogleApiClient.connect();
    }
}

This was from the trivial drive example code I believe. Unfortunately, each of the code examples for different google play services features implement the basegameutils library differently, including the trivial activity example code just for connecting.

I'm also suspect of the constant the example code has you define:

protected static final int REQUEST_CODE_RESOLUTION = 1;

Which conflicts with the 'GameHelperUtils' class constant of:

public static final int R_SIGN_IN_FAILED = 1;

So 'case REQUEST_CODE_RESOLUTION:' in onActivityResult is really 'case R_SIGN_IN_FAILED:'.

Androidcoder
  • 4,389
  • 5
  • 35
  • 50

2 Answers2

0

I think you should handle REQUEST CODE RESOLUTION in onConnectionFailed() method as below.

public void onConnectionFailed(ConnectionResult result) {
  if (!mIntentInProgress && result.hasResolution()) {
    try {
      mIntentInProgress = true;
      startIntentSenderForResult(result.getResolution().getIntentSender(),
          RC_SIGN_IN, null, 0, 0, 0);
    } catch (SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      mIntentInProgress = false;
      mGoogleApiClient.connect();
    }
  }
}

And onActivityResult as below.

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    mIntentInProgress = false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}
siva
  • 1,850
  • 13
  • 14
0

I've found an onActivityResult implementation here Android billing exception which solved this and other issues.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
    // not handled, so handle it ourselves (here's where you'd
    // perform any handling of activity results not related to in-app
    // billing...
    super.onActivityResult(requestCode, resultCode, data);
}
else {
    Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
Community
  • 1
  • 1
Androidcoder
  • 4,389
  • 5
  • 35
  • 50