如何显示Google Play游戏的成就? [英] How to show the google play game achievements?
本文介绍了如何显示Google Play游戏的成就?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经成功集成了Google Play游戏服务,并且能够成功登录.
I have integrated the google play game services successfully and I am able to login successfully.
登录后,我想使用一个按钮向用户显示成就.我已经在代码中完成了以下实现:
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);
在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.
推荐答案
我解决了我的问题,我没有在开发者控制台中发布游戏,但在发布游戏后就可以看到活动的成就
I resolved my problem , I didn't publish the game in developer console , after publishing the game am able to see the achievements in activity
这篇关于如何显示Google Play游戏的成就?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文