【发布时间】:2016-10-09 03:39:02
【问题描述】:
我现在正在创建一个游戏并尝试实现 Google Play Games SignIn。 我的问题是(我认为是)Google Play 游戏没有正确安装在虚拟机上。如果我启动应用程序,它会给我“未安装 Google Play 游戏”的响应(参见图片)。如果您单击“安装”或“取消”按钮,它将再次打开同一屏幕。我不知道为什么。没有显示错误。
这是连接到登录系统的全部代码:
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.d(TAG, "Connection Failed");
if (mResolvingConnectionFailure) {
// Already resolving
return;
}
// If the sign in button was clicked or if auto sign-in is enabled,
// launch the sign-in flow
if (mSignInClicked || mAutoStartSignInFlow) {
mAutoStartSignInFlow = false;
mSignInClicked = false;
mResolvingConnectionFailure = true;
// Attempt to resolve the connection failure using BaseGameUtils.
// The R.string.signin_other_error value should reference a generic
// error string in your strings.xml file, such as "There was
// an issue with sign in, please try again later."
if (!BaseGameUtils.resolveConnectionFailure(this,
mGoogleApiClient, connectionResult,
RC_SIGN_IN, getResources().getString(R.string.signin_other_error))) {
mResolvingConnectionFailure = false;
}
}
// Put code here to display the sign-in button
}
public void onGoogleClick(View view){
mSignInClicked = true;
mGoogleApiClient.connect();
}
@Override
public void onConnected(Bundle connectionHint) {
// show sign-out button, hide the sign-in button
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
Log.d(TAG, "Connected");
Games.Achievements.unlock(mGoogleApiClient, getResources().getString(R.string.ach_lvl3));
// (your code here: update UI, enable functionality that depends on sign in, etc)
}
@Override
public void onConnectionSuspended(int i) {
Log.d(TAG, "Connection Suspended");
}
以及 GoogleApiClient 声明
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
【问题讨论】:
标签: android android-studio google-api google-play-games