在Android上获取电话信息 [英] Get phone call information on android

查看:99
本文介绍了在Android上获取电话信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试找出如何开发我的一个项目的需求.要求是获取有关电话的信息:

I've been trying to figure out how to develop a requirement of one of my projects. The requirement is to get information about phone calls:

  1. 打入/打出电话的时间戳和电话号码
  2. 时间戳和通话结束的原因(通话已结束,用户无法访问网络...)

到目前为止,我发现的内容并不多.下一个链接

What I found until now is not so much. This next link

http://developer.android.com/reference/android/telephony/PhoneStateListener.html

谈论创建侦听器以获取来电电话号码.

Talks about creating a listener to get incoming calls phone number.

任何人都可以为我提供其他功能吗?从哪里获得电话的去电信息?有什么方法可以知道电话何时结束以及原因吗?

Anyone can help me with the rest of functionality? where to get the outgoing information of phone calls? Is there any way to know when a phone call is finished, and the reason?

先谢谢您

推荐答案

    private void getCallLogDetail( Context context ) {
        String[] projection = new String[] {
        BaseColumns._ID,
        CallLog.Calls.NUMBER,
        CallLog.Calls.TYPE,
        CallLog.Calls.DURATION
        };
        ContentResolver resolver = context.getContentResolver();
        Cursor cur = resolver.query(
        CallLog.Calls.CONTENT_URI,
        projection,
        null,
        null,
        CallLog.Calls.DEFAULT_SORT_ORDER );
        if( !cur.isAfterLast()) {
        int numberColumn = cur.getColumnIndex( CallLog.Calls.NUMBER );
        int typeColumn = cur.getColumnIndex( CallLog.Calls.TYPE );
        int durationcolumn = cur.getColumnIndex(CallLog.Calls.DURATION);
        String number = cur.getString( numberColumn );
        String type = cur.getString( typeColumn );
        String duration = cur.getString(durationcolumn);
        cur.moveToNext();

        }

}

这篇关于在Android上获取电话信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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