OnInvitationReceivedListener不能可靠地发射(如果有的话)--Google Play游戏服务按钮点击器[英] OnInvitationReceivedListener does not fire reliably (if at all) - Google Play Game Services Button Clicker

本文是小编为大家收集整理的关于OnInvitationReceivedListener不能可靠地发射(如果有的话)--Google Play游戏服务按钮点击器的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

在尝试"播放游戏服务"的按钮点击器演示时,我没有任何运气(好的,数百次)让OnInvitationReceivedListener开火.

我在这里看过 stackoverflow答案1 在这里 stackoverflow答案2 ,并确保使用测试帐户那是我内心圈子的一部分. (家庭足够好吗?)

在测试中:

我已经尝试在登录另一个用户之前发送邀请(我从来没有让GameHelper Onconnected(Bundle HintConnection)具有非零值).

我已经尝试在两个帐户登录后尝试发送邀请.(1次通知通过并弹出了顶部的视图,要求播放,就是这样),等待了,等待了,等待了任何东西火(日志中的任何内容都没有显示任何发生的事情,并且由于发送邀请没有回报值,因此没有看到邀请的工作方式)

)

我可以(在发件人进入候诊室之后)去看邀请,邀请函在那里.我还可以使用GamesClient LoadInvitation方法,并在该侦听器中获取邀请板.如果我注销了其中一个用户,那么当我邀请另一个测试帐户时,我(有时)在状态栏中收到邀请通知(时间长度从几分钟到最多半小时后),所以我知道邀请正在发送,并且很可能被文档所说的某些东西拦截

public void registerinvitationListener(onInvitationReceivedListener侦听器)

注册听众以拦截接入的邀请 当前签名的用户.如果通过此方法注册听众, 传入邀请不会生成状态栏通知 只要这个客户保持连接.

请注意,一次只有一个侦听器可以活跃.打电话给这个 当另一个听众以前注册的方法将替换 最初的听众与新的听众.参数侦听器 收到新邀请时称呼的听众.这 侦听器在主线程上被调用.

所以我的测试表明第一部分正在工作(呵呵,刚在29分钟前发送了邀请的状态栏通知...)

)

老实说,我不知道第二部分,正如我所说,我永远无法让听众开火!

那么,有什么方法可以获取有关邀请的反馈吗?如果没有,是否还有其他步骤让听众开火?

推荐答案

我遇到了同样的问题.

我不使用BaseGameActivity class.

根据 Android/MultiPlayer#ofer_gameplay ,注册侦听器的正确方法是在onConnected()回调中.

我遵循上述方向,但是从未打过onConnected(),所以我的InvitationListener从未注册.

我的问题是我没有明确要求Plus客户端,并且根本没有注册正确的回调.实施ConnectionCallbacks并覆盖OnConnected()方法还不够 - GameHelper不为您注册回调.

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

注册了两个回调后,我现在在游戏玩法期间收到邀请通知.

本文地址:https://www.itbaoku.cn/post/102571.html

问题描述

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.

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

In testing:

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

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)

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

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.

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.

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?

推荐答案

I was having the same issue.

I do not use the BaseGameActivity class.

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

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

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.