Question

I need to try and get the call duration after a call has ended. I have a broadcast listener which using telephony manager keeps track of the phone states, that is 'offhook', 'idle' and all. Using this receiver i can find out when a outgoing call has been completed. Upon completion of a call, i start a service to fetch the call duration of the last call. However, the value that i get is that of the previous call and not the one that just completed. I think i'm fetching from the calllog DB even before it was updated by the phone. Because if i later call the same function and fetch the value, it gives me the correct time.. Should i somehow put in a delay before starting the service? If yes, how and how much delay?

Was it helpful?

Solution

I figured out how to do it. I made sure the service which fetches from the calllog is started about 2 seconds after the call was ended. This way, I get the correct value and not the previous call duration value as the calllog is updated by then.

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