如何显示google玩游戏的成就?
How to show the google play game achievements?
我已经成功集成了google玩游戏服务,并且可以成功登录。
登录后,我想使用按钮向用户显示成就。我在我的代码中完成了以下实现:
// Create the Google API Client with access to Plus and Games
mGoogleApiClient = new GoogleApiClient.Builder(GameCentreActivity.this)
.addConnectionCallbacks(this)
.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
.addOnConnectionFailedListener(this)
.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
findViewById(R.id.show_achievements).setOnClickListener(this);
在onclick()
方法中,我有这个:
@Override
public void onClick(View view) {
// TODO Auto-generated method stub
if (view.getId() == R.id.sign_in_button) {
//beginUserInitiatedSignIn();
// start the sign-in flow
mSignInClicked = true;
mGoogleApiClient.connect();
}
else if (view.getId() == R.id.sign_out_button) {
// signOut();
// findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
// findViewById(R.id.sign_out_button).setVisibility(View.GONE);
// sign out.
mSignInClicked = false;
Games.signOut(mGoogleApiClient);
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
showSignInBar();
}
else if (view.getId() == R.id.show_achievements){
// startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), 1);
Log.d("Show achievements called","show_achievements");
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),
REQUEST_ACHIEVEMENTS);
Log.d("Show achievements ended","show_achievements");
}
}
但是我的屏幕上根本没有显示成就。请帮助我找到解决方案。
我解决了我的问题,我没有在开发者控制台发布游戏,发布游戏后我可以在 activity
中看到成就
我已经成功集成了google玩游戏服务,并且可以成功登录。
登录后,我想使用按钮向用户显示成就。我在我的代码中完成了以下实现:
// Create the Google API Client with access to Plus and Games
mGoogleApiClient = new GoogleApiClient.Builder(GameCentreActivity.this)
.addConnectionCallbacks(this)
.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL)
.addOnConnectionFailedListener(this)
.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
findViewById(R.id.show_achievements).setOnClickListener(this);
在onclick()
方法中,我有这个:
@Override
public void onClick(View view) {
// TODO Auto-generated method stub
if (view.getId() == R.id.sign_in_button) {
//beginUserInitiatedSignIn();
// start the sign-in flow
mSignInClicked = true;
mGoogleApiClient.connect();
}
else if (view.getId() == R.id.sign_out_button) {
// signOut();
// findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
// findViewById(R.id.sign_out_button).setVisibility(View.GONE);
// sign out.
mSignInClicked = false;
Games.signOut(mGoogleApiClient);
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
showSignInBar();
}
else if (view.getId() == R.id.show_achievements){
// startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), 1);
Log.d("Show achievements called","show_achievements");
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),
REQUEST_ACHIEVEMENTS);
Log.d("Show achievements ended","show_achievements");
}
}
但是我的屏幕上根本没有显示成就。请帮助我找到解决方案。
我解决了我的问题,我没有在开发者控制台发布游戏,发布游戏后我可以在 activity
中看到成就