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..