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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.