如何获取实时传出通话时间? [英] How to get the outgoing call duration in real time?

查看:193
本文介绍了如何获取实时传出通话时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只要有任何呼出它带来了前面的活动。我需要实时呼出时间,并显示在我的活动TextView中。
这是可能得到的电流持续时间,如果通话是摘机?

I have a activity which is brought in front whenever there are any outgoing call. I need the outgoing call duration in real time and show it in my activity textview. Is this possible to get the current duration if call is in offhook?

推荐答案

这是可以做到。你只需要窥探 Android的通话记录内容提供商。要使用内容提供商,你只需要调用 getContentResolver()方法。一旦你有一个内容解析器对象,可以使用SQL或任何内置的查询功能查询。例如,在我的Andr​​oid应用程序,我使用了一块code的,看起来像这样:

This can be done. You just have to Spy on Android Call Log Content Provider. To use a content provider, you just need to call the getContentResolver() method. Once you have a content resolver object, you can query it using SQL or any of the built in query functions. For example, in my Android App, I use a piece of code that looks like this:

    String[] strFields = {
        android.provider.CallLog.Calls.NUMBER, 
        android.provider.CallLog.Calls.TYPE,
        android.provider.CallLog.Calls.CACHED_NAME,
        android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
        android.provider.CallLog.Calls.DURATION 
        };
String strOrder = android.provider.CallLog.Calls.DATE + " DESC"; 

Cursor mCallCursor = getContentResolver().query(
        android.provider.CallLog.Calls.CONTENT_URI,
        strFields,
        null,
        null,
        strOrder
        );

看看这个漂亮的小补习在这里。

这篇关于如何获取实时传出通话时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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