Game Services Alert in Notification Bar, but no call to onTurnBasedMatchUpdated()? - android

When I call takeTurn(), I will get a call to onTurnBasedMatchUpdated() on the same device that called takeTurn(). But I will not get the call to onTurnBasedMatchUpdated() on the other device that is waiting for its turn. Instead, Game Services will alert the device that it is their turn to play in the notification bar. I was hoping that, if the device remained in-game, that the game would continue to catch onTurnBasedMatchUpdated() when the other player calls takeTurn(). So how do I prevent the notification and simply handle the call?

As Mannan pointed out, it is onTurnBasedMatchReceived() that is called when an opponent takes their turn. It is also called when an opponent connects to your match for the first time. While this function is required to be defined for an "OnTurnBasedMatchUpdatedListener" it is not actually called for that listener. You must ALSO implement "OnTurnBasedMatchUpdateReceivedListener". Further, after implementing it, you must then REGISTER it (I do so after signing in) with getGamesClient().registerMatchUpdateListener(this). Seriously though, where is all the documentation for this? Am I missing something?

When a player's turn is arrived, following callback is called,
onTurnBasedMatchReceived(TurnBasedMatch match)
and in this callback, you can get info about the turn and its data from match parameter.
I still dont know why onTurnBasedMatchUpdated() is not called.

Related

Turn Based Game player receives its own data without opponent calling takeTurn

I have been implementing my own turn based board game. Whole game is based on PlayGameService's SkeletonTbmp example with some modifications.
My problem is that a player sometimes receives its own data that it sent to the opponent using takeTurn(). I have checked many times that getNextParticipantId() returns the right id. For example my emulator persists a move data and sends it correctly to my actual Android phone and my phone unpersists as implemented in the example. Then some seconds later my emulator receives this same data without actual device persisting it and calling takeTurn(). This also happens sometimes on game start on the first turn, emulator receives the first "dummy" turn data without actual device sending anything yet. It does not happen every single turn, just occasionally.
Could this be something with my Google Play Console settings or does these turns buffer some how and then they are released at some point?
As you have not giving any codes i cannot pinpoint the problem. But just for the explanation, as long as the match is going, match will contain data, whether its your turn or not. To pinpoint the exact place this is happening, put checks at the execution of updatematch() as it must be firing without actual need. (on login, reconnect, initiate, connectionhint etc). Can't be sure about your code but alternate approach to bypass the bug, you can actually put check on turncounter in addition of MATCH_TURN_STATUS_MY_TURN otherwise pass the null turn. Hope it helps as further i cant help without your code.
It seems that i just forgot to always remove the old games from the "check games"-UI, thats why it sends the same data after a while, when i am already attending to a new game with same opponent.

How to detect fake call log created by apps

Play store has numerous apps those creates fake call logs.But, sometimes it's important to detect is that call log real or fake to save yourself being a fool. Can anybody tell me how can we detect same?
If these apps are writing to the actual android call log, I don't think there is much you can do against that.
However, you might want to try the below solution, which can maintain your own call list based on the device behaviour.
In Android you can listen for incoming and outgoing calls, using a BroadcastReceiver. Here is a good tutorial for it:
https://www.codeproject.com/Articles/548416/Detecting-incoming-and-outgoing-phone-calls-on-And
If you implement it correctly, you will only receive events from calls being executed for real. So you can save them in your app's call log.

How should I Implement TBMP Rematch?

I'm creating a multiplayer tic tac toe game and it works for the most part, but when it's time to rematch I'm getting less than desirable functionality.
So originally I used the same implementation of Games.TurnBasedMultiplayer.rematch as the TBMPSkeleton sample project. Basically after calling Games.TurnBasedMultiplayer.finish, I check whether or not the match can be rematched by calling match.canRematch() during the subsequent callback. If match.canRematch() returns true, then I call Games.TurnBasedMultiplayer.rematch. Both, when I call finish and when I call rematch, the onTurnBasedMatchReceived callback gets called on the opposing client device and from there I check the match object for the rematchId. If it's not null, then I reset the game.
The problem I'm having is that, after the winning player has requested a rematch and then takes his/her turn, the opposing player receives an invite to the new match, but the onTurnBasedMatchReceived callback doesn't get called. I don't want the losing player to have to leave my game in order to accept or dismiss the invitation.
So is there a way to have my app handle the invitation notification without forcing the player to have to open the system's notification gui? Should I scrap the turn based multiplayer API in favor of it's real-time counterpart?
I realized that I didn't have a listener registered for invitations. After registering one, I was able to achieve my desired functionality. I'm relieved that it's working, but it would have been nice to notice that much sooner...

How to Get Outgoing call duration with Twilio Client API in Android?

I have developed Twilio SDK in my Android application. For outgoing and incoming it is worked well. But when i try to set the timer for call duration, i am unable to get the notification from the other device. Is there any method to find out the other device(Which was notified after picking the call)?
Please help me on this.
Thanks,
I'm not sure if you still need help with this or not, or I get exactly your issue.
What I'm doing is keeping the timestamp of when the call was started (incoming/outgoing) in any of the clients. Then in my activity/fragment, since I have my own callbacks for the Twilio events, as soon as I know there's a call going on, I use Chronometer which is like a TextView that automatically sets things as soon as you set a base time and start it.
get timestamp of when that call started
Chronometer.setBase(timestamp);
Chonometer.start();
So it shows the duration. Remember to have your own Twilio manager class to hold that value for you so if you leave your activity and come back, the duration will be displayed correctly.
Good luck

How do I know who ended the call in Android - User or Remote User?

I want to specifically know who ended the call. I have setup a broadcast receiver for
"android.intent.action.PHONE_STATE"
When I detect a transition from Off hook to idle, I know the call has ended. But how do I know who ended the call?
Thanks a ton!
I'm afraid there's presently no way to determine if the user pressed "end call" or if the other end (or ends, in a group call) terminated. The only workaround I can suggest is monitoring the other states to observe if the phone state ringing was encountered. In such a case, you could assume the user is making the phone call as opposed to receiving it.
Bear in mind that there are other problems related to PHONE_STATE, such as handling multiple calls simultaneously.
In retrospect, I'm not entirely sure what you mean with "who". As for other apps ending the call: there is no official API to end phone calls; only through reflection can an app invoke the TelephonyService's endCall() function. Here, too, it is not possible to determine if the call was terminated through user interaction or not.

Categories

Resources