[英]How to show the google play game achievements?
I have integrated the google play game services successfully and I am able to login successfully. 我已经成功集成了Google Play游戏服务,并且能够成功登录。
After the login, I want to show the achievements to the user using a button. 登录后,我想使用一个按钮向用户显示成就。 I have done the following implementation in my code:
我已经在代码中完成了以下实现:
// 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);
In the onclick()
method, I have 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");
}
}
But the achievements are not displaying at all in my screen. 但是成就没有显示在我的屏幕上。 Please help me in finding the solution.
请帮助我找到解决方案。
我解决了我的问题,但是我没有在开发者控制台中发布游戏,所以在发布游戏之后就可以看到活动的成果了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.