Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
796 views
in Technique[技术] by (71.8m points)

android - How to show the google play game achievements?

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);

In the onclick() method, I have this:

  @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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...