访问android平台的通话记录CallLog
来源:互联网 发布:linux中echo 编辑:程序博客网 时间:2024/06/05 00:35
android平台上的通话记录是以Content Provider的形式存储在手机上的,因此你需要使用ContentResolver来查询通话记录,返回Cursor接口。如下所示:
package com.me;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.CallLog;
import android.widget.SimpleAdapter;
import android.widget.SimpleCursorAdapter;
public class CallLogActivity extends ListActivity {
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.main);
Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI,
null, null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
startManagingCursor(cursor);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1, cursor,
new String[] { CallLog.Calls.NUMBER },
new int[] { android.R.id.text1 });
setListAdapter(adapter);
}
}
获得了Cursor之后便可以构建一个Adapter然后调用setListAdapter()来把通话记录显示在屏幕上。CallLog类中定义了Calls类,在android中可以看到大量的内部类的设计。Calls定义了很多常量,方便你来访问通话记录,主要包括两个URI和多个字段定义,比如我们在这里用到的NUMBER。更多内容请参考Andorid doc。
下面是/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No Notes!"/>
</LinearLayout>
- 访问android平台的通话记录CallLog
- 访问android平台的通话记录CallLog
- 访问android平台的通话记录CallLog
- 访问通话记录CallLog
- 获取android系统通话记录CallLog
- Android通话记录CallLog简单摘要
- Android ContentResolver CallLog 获取手机通话记录
- android 通话记录的导入/导出
- Android模拟系统的Calllog,统计打电话时间和发送短信的个数
- 打补丁去掉Android手机的短信通话记录
- android 通话记录的查询与删除
- android 通话记录的查询与删除
- android 通话记录的增删改查
- android 通话记录的查询与删除
- android删除某个号码的通话记录
- android 通话记录条数的限制
- android 通话记录的查询与删除
- android通话记录的查询与删除
- .Net下的加密解密大全(5):玩转对称加密
- 视讯音频标准推陈出新,谁是音频效果之霸?
- LaTeX使用--使用XeLaTeX支持中文(可以放弃Office了)
- FlexClient, MessageClient, and FlexSession
- 基于用户组织角色权限和资源的五要素
- 访问android平台的通话记录CallLog
- VMware虚拟机不能发声
- Java NIO 写文件
- 04_IHE简介
- sohu单点登录
- Log4j的html输出格式:HTMLLayout 类重写,根据自身需要输出不同列
- C语言关键字学习(1)----- extern
- 实例讲解1--模式匹配
- Js_异常处理