How to Get Outgoing call duration with Twilio Client API in Android? - 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

Related

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.

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

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.

How to trigger a status bar notification without starting the actual view in android?

I am new to android development and I did research on notifications using toast and status bar notification.
And I also managed to execute the code properly to make a notification work!!!
The problem is there are only methods like triggering a notification by clicking a button is available. Other wise I managed to directly call the codes within the method that is called by the button, to make it trigger automatically. But the problem is the view of the corresponding screen is showing up a tleast for a sec and then closing while this notification is triggered.
So how can i write a code that just triggers the notification without popping up the screen even for a second.
I need a result like the way the new SMS alert works...And I did a lot of research on this and all I got was about basic notification. So please help as I am new to this!!!
Using a Service would be the "right" way to do it - and if this is a professional app you are writing, then that's the way to go.
Bear in mind you still need some activities in your application, in order to trigger the service.
If you are just experimenting, then maybe what you need is a cheap hack...
Here's the cheap and nasty way to get your proof-of-concept done:
either - create a transparent Activity so that nothing is displayed when the activity code gets called.
or - create your notification from within the Activity.onCreate() method, and then call finish() at the end of that method. Your activity will never get shown to the user.
To me, it looks like you are just experimenting, and a transparent activity might get you further faster... ymmv
Legendary you need service and handler. Using service you can get data. and using handler you can modify the UI of your app.
here you can get more information on it.
http://developer.android.com/training/notify-user/display-progress.html
Working with handlers and threads in service, Thread.sleep makes the program to hang?

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.

Binding activity to a running service in android

I have a service S that starts at boot.
It has a contentobserver C that starts an intentservice X to do some processing.
The default activity A is started by the user.
I want to know if it's possible to bind A to the running service S without stopping it so that I can pass on a resultreceiver R to S that in turn has to be passed on to X.
I want to achieve this so that I can start X again, this time free from C, from the bound service S with R as a parcelable extra.
Via R, a progress dialog is updated in A whenever it's run.
Before trying my luck with resultreceivers, I was using notifications, the one from the support library.
But the problem was that I was building and showing them again for each iteration of a loop.
The alert sound was playing repeatedly for like 300 odd times and that was unpleasant.
Tried my luck with broadcasts but I had some bad experiences. So tossed them away.
Is there any other way around this problem?
My problem could be solved if there's a way to update the notification with building it again.
I'm using 4.1.1 build, API 16 in which setlatesteventinfo seems to be deprecated.
I am still open to go back to the idea of updating a running notification.
Or a different workaround.
Any help will be appreciated.
EDIT:
Using notifications is a way to implement this app in which there would be no need for the resultreceiver and ibinder interfaces.
I can't find the setlatesteventinfo in the API level 16. I'm trying to use the v4 support library. In my implementation, I build a new notification for every iteration of a loop. But I've not figured out a way to keep the sound alert for the first time only and not for the rest. Has anybody succeeded in properly updating a notification?
I want to know if it's possible to bind A to the running service S without stopping it
That is certainly possible. As Hoan pointed out, you need to call bindService() from your activity. This article has some example code on how to do it.
As for the rest of your question, it seems like it could be broken down into several new questions. It's really hard to comprehend and answer all at once.
The android documentation on Bound Services says:
The third parameter is a flag indicating options for the binding. It should usually be BIND_AUTO_CREATE in order to create the service if its not already alive.
Still have to confirm that the onCreate() of service S is not called again though.

Categories

Resources