1

What is happening is very strange.
Whenever user sign-in is initiated, the "choose an account" view appears, after choosing an account and clicking OK, the sign-in is initiated again and the same view returns. Clicking cancel returns to the game with failed sign in, why is this happening?

The following comes up in LogCat before the sign in is initiated:

03-06 13:53:06.797: D/PhoneWindow(2967): couldn't save which view has focus    
because the focused view org.cocos2dx.lib.Cocos2dxGLSurfaceView@40537408 has no id.

I've implemented like so:

public class myapp extends BaseGameActivity {
   ...
   static Context mContext;
   boolean mInSignInFlow = false;
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState); 
    mContext = myapp.this;
    if(GooglePlayServicesUtil.isGooglePlayServicesAvailable (mContext) == ConnectionResult.SUCCESS){
        GoogleApiClient.Builder builder = 
               new GoogleApiClient.Builder(this);
               builder.addApi(Games.API)   
                  .addScope(Games.SCOPE_GAMES);
                mClient = builder.build();

       }
}

@Override
protected void onStart() {
    super.onStart();
    if (!mInSignInFlow) {
        // auto sign in
        mClient.connect();
    }
}
@Override
public void onSignInFailed() {
    Log.w("Sign In", "Failed");
}

@Override
public void onSignInSucceeded() {
    mInSignInFlow = true;
    Log.w("Sign In", "Success");
} 

public static void gameServicesSignIn() {
    ((myapp)mContext).runOnUiThread(new Runnable() {
        public void run() {
            ((myapp)mContext).beginUserInitiatedSignIn();
        }
    });
}

I get "Sign in Failed" Log on startup and the situation i described above when gameServicesSignIn() is called from button click..

1
  • Could you post more code ? How are you prompting the login screen ? Mar 6, 2014 at 19:49

2 Answers 2

1

It appears that you are not building correctly. Looking thru the flow (if you extend BaseGameActivity) the underlying setup of the Helper is already taken care of for you.

From BaseGameActivity

public GameHelper getGameHelper() {
    if (mHelper == null) {
        mHelper = new GameHelper(this, mRequestedClients);
        mHelper.enableDebugLog(mDebugLog);
    }
    return mHelper;
}

@Override
protected void onCreate(Bundle b) {
    super.onCreate(b);
    if (mHelper == null) {
        getGameHelper();
    }
    mHelper.setup(this);
}

This will then also take care of setting up the listeners to call your onSignInFailed/Succeded.

The setup stuff I see in your code is for when you aren't extending BaseGameActivity.

0

in Android, if you are using OpenGL (the case of cocos2d-x) you need to set:

cb.setImpressionsUseActivities(true);

And after setting this you will need to put the below code on the AndroidManifest.xml as well:

<activity android:name="com.example.Activity"
    android:excludeFromRecents="true"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

I really don't know anything about cocos2d-x so I hope this helps.

1
  • Well I don't believe this is a cocos2dx issue, but something with my implementation of Google Play Game Services. Does my above integration look proper? Mar 6, 2014 at 22:11

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.