OnInvitationReceivedListener无法可靠地触发(如果有的话) - 谷歌玩游戏服务按钮唱首歌 [英] OnInvitationReceivedListener does not fire reliably (if at all) - Google Play Game Services Button Clicker

查看:284
本文介绍了OnInvitationReceivedListener无法可靠地触发(如果有的话) - 谷歌玩游戏服务按钮唱首歌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试播放游戏服务的按钮,点击者的演示,我还没有任何运气(好吧,1次出数百)获得OnInvitationReceivedListener火了。

In trying out the button clicker demo of the Play Game Services, I have not had any luck (ok, 1 time out of hundreds) of getting the OnInvitationReceivedListener to fire.

我在这里看了<一href="http://stackoverflow.com/questions/17149066/send-notification-when-inviting-to-multiplayer-game-game-services">stackoverflow回答1 这里<一href="http://stackoverflow.com/questions/16879068/google-play-game-services-invitations-get-lost">stackoverflow回答2 ,并取得了一定要使用测试帐户是我的内部圈​​子的一部分。 (家庭不够好?)

I have looked here stackoverflow answer 1 and here stackoverflow answer 2, and have made sure to use test accounts that are part of my inner circles. (family good enough?)

在测试:

我曾尝试发送的邀请中的其他用户登录(我从来没有得到的gameHelper onConnected(包hintConnection)有一个非空值)。

I have tried sending the invitation prior to logging in the other user (I Have never gotten the gameHelper onConnected(Bundle hintConnection) to have a non null value).

我试图发送邀请后两个账户都登录。(1时间通知来通过和弹出视图顶部要求发挥,这就是它),并一直在等待,等待,等待什么火(没有在日志中显示过什么发生,因为有用于发送的邀请,没有看到有关如何邀请做无返回值)

I have tried sending the invitation after both accounts are logged in. (1 time a notification came through and popped up the view at the top asking to play, that's it) and have waited, and waited, and waited for anything to fire (nothing in the logs ever shows anything happening, and since there is no return value for sending the invite, nothing to see about how the invite is doing)

我可以(右后发送方进入候车室)去看看请柬和邀请是存在的。我还可以使用GamesClient loadInvitations方法,并获得invitationBuffer回该侦听器。如果我注销用户之一,那么我(有时)获得邀请函的通知状态栏,当我邀请其他测试帐户(时间从几分钟变化,以达到一个半小时后),所以我知道邀请被发送出去,而且极有可能截获的东西,如文档说

I can (right after the sender goes into the Waiting Room) go to See Invitations and the invitation is there. I can also use the GamesClient loadInvitations method, and get the invitationBuffer back in that listener. If I log out one of the users, then I (sometimes) get Invitation notifications in the status bar when I invite the other test account(length of time varies from a few minutes, to up to a half hour later), so I know the invitations are being sent out, and most likely intercepted by something as the documentation says

公共无效registerInvitationListener(OnInvitationReceivedListener监听器)

public void registerInvitationListener (OnInvitationReceivedListener listener)

注册一个监听器,拦截来袭的邀请书   当前登录的用户。如果一个监听器通过此方法注册的,   传入的​​邀请,将不会产生一个状态栏通知作为   只要此客户端仍连接。

Register a listener to intercept incoming invitations for the currently signed-in user. If a listener is registered by this method, the incoming invitation will not generate a status bar notification as long as this client remains connected.

请注意,只有一个监听器可以是活动的时间。调用此   方法而另一个监听器是pviously注册将取代$ P $   原监听器与新的。参数监听器   侦听器接收到新的邀请时调用。该   监听器被称为主线程。

Note that only one listener may be active at a time. Calling this method while another listener was previously registered will replace the original listener with the new one. Parameters listener the listener that is called when a new invitation is received. The listener is called on the main thread.

所以,我的测试显示第一部分工作(呵呵,刚刚得到的一个状态栏通知的邀请发送44分钟以前打字时这样...)

So my testing shows the first part is working (hehe, just got a status bar notification of an invite sent 29 minutes ago while typing this...)

我真的不知道第二部分,正如我所说,我永远不能让听者火!

I honestly don't know about the second part, as I said, I can't ever get the listener to fire!

那么,有没有什么办法让有关邀请的反馈?如果没有,还有什么必要步骤,让听者火?

So, is there any way to get feedback about the Invitation? If not, are there any other steps necessary to get the listener to fire?

推荐答案

我有同样的问题。

我不使用 BaseGameActivity 类。

根据 https://developers.google.com/games/services/安卓/多人#during_gameplay ,正确的方法来注册监听是在 onConnected()回调。

According to https://developers.google.com/games/services/android/multiplayer#during_gameplay , the proper way to register the listener is in the onConnected() callback.

我跟着上面的指示,但 onConnected()从来没有叫,所以我的 InvitationListener 从来没有登记。

I followed the above directions, but onConnected() was never called, so my InvitationListener was never registered.

我的问题是,我并没有明确要求加号的客户,而我并没有登记正确的回调都没有。实施 ConnectionCallbacks 并重写 OnConnected()的方法是不够的 - 对 GameHelper 不注册回调给你。

My problem was that I wasn't explicitly requesting the Plus client, and I wasn't registering the proper callback at all. Implementing ConnectionCallbacks and overriding the OnConnected() method isn't enough - the GameHelper doesn't register the callback for you.

public class MainActivity extends AndroidApplication implements
    ..., ConnectionCallbacks,
    OnInvitationReceivedListener {

...
@Override
public void onCreate(Bundle savedInstanceState) {
  ...
  gameHelper = new GameHelper(this);
  gameHelper.setup(this, GameHelper.CLIENT_GAMES | GameHelper.CLIENT_PLUS);
  gameHelper.getPlusClient().registerConnectionCallbacks(this);
  ...
}

@Override
public void onConnected(Bundle connectionHint) {

  gameHelper.getGamesClient().registerInvitationListener(this); 
  ...
}

注册正确的两次回调后,我现在在游戏中收到邀请通知。

After registering the proper two callbacks, I now receive invitation notifications during gameplay.

这篇关于OnInvitationReceivedListener无法可靠地触发(如果有的话) - 谷歌玩游戏服务按钮唱首歌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆