取回通话时间从Calllog使用BroadcastListener通话结束后, [英] Fetching Call duration from Calllog after call ends using BroadcastListener

查看:175
本文介绍了取回通话时间从Calllog使用BroadcastListener通话结束后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要尝试并获得通话时间在通话结束后。我有一个广播监听器,使用电话管理器保持的电话状态轨迹,那就是摘机,空闲和所有。使用该接收机,可以找出当呼出已经完成。当通话结束后,我启动服务来获取最后一个电话的通话时间。但是,我得到的价值在于previous调用,而不是刚刚完成的一个。我想我从calllog DB之前它是由手机更新获取。因为如果我以后调用相同的功能,获取的价值,它给了我正确的时间..我应该以某种方式将在启动该服务之前的延迟?如果是的话,怎么怎么样拖了那么久?

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?

推荐答案

我想通了,如何做到这一点。我确信它取出由calllog该服务已启动约2秒通话结束之后。这样一来,我得到正确的值,而不是作为calllog被随后更新了previous通话时间的价值。

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.

这篇关于取回通话时间从Calllog使用BroadcastListener通话结束后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆