简体   繁体   中英

Google Play Game Services, Android, accepting quests in Play Gams app

I'm working through the Quality Checklist for Google Play Games Services

Under point 9.2

Allow players to accept quests from the Play Games app.

Your game must bring up a view to allow players to accept a quest when they click on a quest tile in the Play Games app.

I go into the Play Games app. I find my game. I see the Quests tab, I open that. I see a list of quests. On each quest tile, it says "Play".

Now, this quality checklist wants me to bring up a specific view when they get into the game that allows the quest to be accepted.

I can't find anything pertaining to specifically showing a view like this. I haven't spotted any special information in the Intent that's used to launch my app.

How do I go about figuring out that you came into my game from a specific quest tile in the Play Games app?

Or can I explicitly set a different Activity to be fired from those quest tiles?

We spent a few hours for the same question and the answer was simple.

Just use https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient.ConnectionCallbacks

and callback registration https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient#registerConnectionCallbacks(com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks)

    gameHelper.getApiClient().registerConnectionCallbacks(
    new GoogleApiClient.ConnectionCallbacks() {

        @Override
        public void onConnected(Bundle bundle) {
            // If the game started via Accept quest button in Google Play Games,
            // we will got here a bundle with all information
            if (bundle == null)
                return;

            QuestEntity questEntity = bundle.getParcelable(Games.Quests.EXTRA_QUEST);

            if (questEntity == null)
                return;

           activity.startActivityForResult(Games.Quests.getQuestIntent(gameHelper.getApiClient(), questEntity.getQuestId()), REQUEST_CODE_QUEST_UI);
       }

       @Override
       void onConnectionSuspended(int cause){}
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM