android - 如何显示google play游戏成就?

标签 android google-play-games

我已经成功集成了 google play 游戏服务,并且能够成功登录。

登录后,我想使用按钮向用户显示成就。我在我的代码中做了以下实现:

// 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 中看到成就

关于android - 如何显示google play游戏成就?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34409334/

相关文章:

android - 如何在 Android 应用程序中永久禁用 NDEF 标签发现而不仅仅是 Activity?

java - 更新应用时如何让所有现有用户退出 Google?

Android - Google Play 游戏服务,找不到方法 android.view.View.getDisplay

c++ - Google Play 游戏服务可以用于 PC 游戏吗? ( Windows/Linux/OSX)

android - 如何使用 Gradle 在 Intellij Idea 中将 Android 项目设置为子项目

java - 获取按钮坐标并检测手指是否在它们上面 - Android

android - 如何在 flutter 中使用依赖注入(inject)?

android - Google Play 反盗版 - 排行榜中的作弊分数

android - 显示成就UI();不想出现在 Android 上

java - 是否可以确定 Android 位图上 png 压缩的类型?