Google Play游戏服务,Android,接受Play游戏应用中的任务

时间:2015-03-17 20:17:10

标签: android google-play google-play-services google-play-games

我正在完成Quality Checklist for Google Play Games Services

第9.2点

  

允许玩家接受Play游戏应用中的任务。

     

你的游戏必须提出一个视图,允许玩家在点击Play游戏应用中的任务牌时接受任务。

我进入了Play游戏应用。我找到了我的游戏。我看到了Quests选项卡,我打开它。我看到了一系列任务。在每个任务图块上,它显示“播放”。

现在,这个质量检查表要求我在进入允许接受任务的游戏时调出特定的视图。

我找不到任何有关专门显示此类视图的内容。我没有在用于启动我的应用程序的Intent中发现任何特殊信息。

如何确定您是否从Play游戏应用中的特定任务图块进入我的游戏?

或者我可以显式设置从这些任务图块中触发的不同活动吗?

1 个答案:

答案 0 :(得分:1)

我们花了几个小时来讨论同样的问题,答案很简单。

只需使用 https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient.ConnectionCallbacks

和回拨注册 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){}
    });