Question

My Activity is implementing OnInvitationReceivedListener along with all the other game services items. It requires that I have the onInvitationReceived function implemented (i.e. gives an error if I don't) so that's good. The problem is, I can send my account an invite and it will not call the onInvitationReceived function. The other listeners work and I can start a game and whatnot by opening the invitation list and accepting it, but this function simply never gets called. It should also consume the event but I still get an external notification as well.

Am I missing something? Is it not as simple as the below? All the other listeners work...

public class MyActivity extends BaseGameActivity
    implements View.OnClickListener, RealTimeMessageReceivedListener,
    RoomStatusUpdateListener, RoomUpdateListener, OnInvitationReceivedListener
{
    public MyActivity(){...}
    ...

    public void onInvitationReceived(Invitation arg0) 
    {
        Log.v("meh", "Invitation Received");
    }
}
Was it helpful?

Solution

Are you registering MyActivity for the callback?

Since you are using BaseGameActivity, try putting this in your post-connection callback:

getGamesClient().registerInvitationListener(this);

I'm somewhat surprised that this isn't done for you, but in looking at the BaseGameActivity class I don't see it.

OTHER TIPS

I was having similar issues. (I still haven't cracked the code on the invite Bundle not being null everytime I start up the service... even when there are invitations waiting...)

From here Previous StackOverflow issue for Invitaion Listener I did get the issue mostly solved. (in that i do get notifications in my app code that a new invite has come in) However, there is nothing to tell you if an invite has been rescinded...

So, I also run a Timer and do this in my code:

@Override
    public void loadInvitations(){
        mHelper.getGamesClient().loadInvitations(new OnInvitationsLoadedListener() {

            @Override
            public void onInvitationsLoaded(int statusCode, InvitationBuffer buffer) {
                dLog("invitations loaded " + buffer.getCount());
                if(mHelper.getGamesClient().STATUS_OK == statusCode  && buffer.getCount() > 0){
                    if(mGHInterface != null){
                        mGHInterface.haveInvitations(buffer.getCount());
                    } 
                } else if (mGHInterface != null){
                    mGHInterface.haveInvitations(0);
                }

            }
        });
    }

Up to you on how often you want to run this, but this way I have found that at least I do know if invitations exist or not, and update my app's actions accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top