java - Android Google Play notification does not bring user to game screen -


similar questions have been trivial @ best answers. using faily up-to-date google play game services apk 'com.google.android.gms:play-services:7.0.0' , have oninvitationreceived() , onconnected() implemented.

however, oninvitationreceived() doesn't seem called when invitee accepts game invite in-game. , while i'm onconnected() called no matter when player connects via callback after mgoogleclient.connect() , seems invitation dropped or because player not redirected game screen specified if bundle contains invitation (i'm assuming called when app closed either way, status bar notification shown invite).

any insight appreciated. here relevant methods:

onconnected() class, extends androidgame, , androidgame extends activity (i've tried in both classes, have overridden in child class of androidgame):

@override public void onconnected(bundle connectionhint) {     // connected google play services!     // stuff goes here.     games.invitations.registerinvitationlistener(mgoogleclient, network.getinstance().mlistener);      if (connectionhint != null) {         invitation inv =                 connectionhint.getparcelable(multiplayer.extra_invitation);          if (inv != null) {             // accept invitation             roomconfig.builder roomconfigbuilder = roomconfig.builder(network.getinstance());             roomconfigbuilder.setmessagereceivedlistener(network.getinstance());             roomconfigbuilder.setroomstatusupdatelistener(network.getinstance());             roomconfigbuilder.setinvitationidtoaccept(inv.getinvitationid());             roomconfig roomconfig = roomconfigbuilder.build();             games.realtimemultiplayer.join(mgoogleclient, roomconfig);              // prevent screen sleeping during handshake             getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on);              // go game screen             setscreen(new charselectscreen(this));         }     } } 

oninvitationreceived network class, singleton handles other listeners well. oninvitationreceived() both overridden in network class , in anonymous inner class, cover assets:

@override     public void oninvitationreceived(invitation invitation) {         intent intent = games.invitations.getinvitationinboxintent(game.getgoogleclient());         game.startactivityforresult(intent, rc_invitation_inbox);          mincominginvitationid = invitation.getinvitationid();         alertdialog.builder builder = new alertdialog.builder(game.getapplicationcontext());         builder.setmessage("join game?")                 .settitle("bit game invitation!");         builder.setpositivebutton("join", new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int id) {                 if(!game.getgoogleclient().isconnected()) {                     game.getgoogleclient().connect();                 }                 // user clicked ok button                 bundle = roomconfig.createautomatchcriteria(1, 3, 0);                 roomconfig.builder roomconfigbuilder = roomconfig.builder(network.getinstance());                 roomconfigbuilder.setmessagereceivedlistener(network.getinstance());                 roomconfigbuilder.setroomstatusupdatelistener(network.getinstance());                 roomconfigbuilder.setautomatchcriteria(am);                 roomconfigbuilder.setinvitationidtoaccept(mincominginvitationid);                 roomconfig roomconfig = roomconfigbuilder.build();                 games.realtimemultiplayer.join(game.getgoogleclient(), roomconfig);                  // prevent screen sleeping during handshake                 game.getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on);                 dialog.dismiss();                  // go game screen                 game.setscreen(new charselectscreen(game));             }         });         builder.setnegativebutton("cancel", new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int id) {                 // user cancelled dialog                 dialog.dismiss();             }         });         alertdialog dialog = builder.create();         dialog.show(); 

i solved it, short answer being did not follow android realtime multiplayer recipe (guidelines) closely should have.

the guidelines calls easy access google play sign-in, either automatically when starting app or i'd imagine preferably, button sign in. when added this, callback onconnected() code worked, invitation allowed user proceed designated game screen default waiting room pop-up (implementation shown here). still debugging oninvitationreceived() callback, suspect when invitation received when game open, game crash means there wrong implementation.

all in all, think bit of misunderstanding on end, documentation intuitive. thank helping, , hope future google play game services developers.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -