Fetching Call duration from Calllog after call ends using BroadcastListener

余生长醉 提交于 2019-12-24 04:23:19

问题


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.



来源:https://stackoverflow.com/questions/13509958/fetching-call-duration-from-calllog-after-call-ends-using-broadcastlistener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!