- 浏览: 57698 次
- 性别:
- 来自: 成都
文章分类
最新评论
转载自:http://android.tgbus.com/Android/androidnews/200902/178074.shtml
Android平台开放程度的确很厉害,你几乎可以调用任何底层的接口,甚至拦截到短信或者呼入电话。这些是J2ME平台无法比拟的。本文介绍一下如何访问android的通话记录。
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平台开放程度的确很厉害,你几乎可以调用任何底层的接口,甚至拦截到短信或者呼入电话。这些是J2ME平台无法比拟的。本文介绍一下如何访问android的通话记录。
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>
发表评论
-
TextView 的属性
2013-04-17 17:45 556收集到了TextView 的属性 ... -
ADT在线安装
2012-11-09 09:53 780注:转载自http://blog.csdn.net/kieve ... -
android 界面布局 很好的一篇总结 【转】
2012-04-26 15:24 916出处:http://www.cnblogs.com/awe ... -
android xml属性大全
2012-03-15 09:12 1013Android activity属性 android:all ... -
Android开发之屏幕大小自适应
2012-01-31 14:19 838屏幕大小: 一:不同的layout Android手机屏幕大小 ... -
Intent常用Uri
2012-01-21 09:37 802一、打开一个网页,类别是Intent.ACTION_VIEW ... -
android raw读取超过1M文件的方法
2011-11-01 15:48 823转载自:http://www.cnblogs.com/yaos ... -
Android Bitmap用法总结
2011-10-09 10:57 963转载自:http://blog.csdn.net/zhou69 ... -
Android之TextView------属性大全
2011-09-22 16:32 683android:autoLink设置是否当 ... -
Android内存泄漏简介
2011-09-09 16:28 806前言 不少人认为JAV ... -
Android的Parcel机制
2011-09-06 15:09 4017转载至:http://blog.csdn.net/caowen ... -
Android Context
2011-09-01 17:12 918在android中context可以作很多操作,但是最主要的功 ... -
android面试题
2011-06-27 11:57 9811.什么是Activity? 2.请描 ... -
android中的hdpi,ldpi,mdpi
2011-06-17 14:31 658Android2.1 和之后的版本 中的 drawable(h ... -
Android横竖屏
2011-06-08 11:22 855要解决的问题应该就两个: 一。布局问题; 二。重新载入问题。 ... -
Android软件权限知识普及
2011-05-27 11:08 859APK权限详细对照表 您的 ... -
Android调用WebService
2011-05-18 13:42 1059转载至:http://express.ruanko.com/r ... -
android实用代码片段
2011-05-06 10:58 7291. android获取到系统是24小时制还是12小时制 ... -
Android 应用程序退出的四种方法
2011-05-04 09:33 1465Android程序有很多Activi ... -
开发者不得不知的Android权限说明
2011-04-21 10:55 678程序执行需要读取到安全敏感项必需在androidmanifes ...
相关推荐
Android call/calllog 详细流程图
系统的通话记录,是通过 ContentProvider 来对外共享的 Uri CallLog.Calls.CONTENT_URI : 等价于:Uri.parse("content://call_log/calls"); 查询出所有记录 ContentResolver resolver = getContentResolver();...
android里面,往短信和通话记录插入数据的一些代码。
Android获取手机通话记录,封装工具类,显示通话记录到listview中。
Android如何获取手机通话记录,本文为大家揭晓。 获取手机通话记录流程: 1、 获取ContentResolver; ContentResolver resolver = getContentResolver(); 2、resolver.query(*); 需要传入通话记录的URI:...
android中calllog简介,以及做contacts时遇到的几个问题。
在linux当中每隔10S生成一行callLog的数据,用'java -cp calllogs-0.0.1-SNAPSHOT.jar product.AutoDataGen ./nam_num.csv ./calllog.csv'运行,其中nam_num.csv为姓名手机号映射的文件
简单的通话记录应用,以及对listview的使用。
mtk phonebook calllog FAQ ,相当牛X的文档,注意用来解答这两块的问题。
android电话、短信黑白名单拦截、电话录音等综合实现实例
calllog_show.war
的 Android SDK 提供了在 Android 平台上使用 JaVa 语言进行 Android 应用开发必须的工具和 API 接口。 特性 • 应用程序框架 支持组件的重用与替换 • Dalvik Dalvik Dalvik Dalvik 虚拟机 专为移动设备优化 • ...
cordova.plugin.call.logcallLog.getCallLog(callNumber, function (success) { //成功}, function (error) { //失败})结果:[{"CallDate":"","Duration":""}]
针对手机被盗带来的隐私数据泄露问题,提出了一种利用IMSI(international mobile subscriber identification number)检测和人脸识别的手机防盗追踪系统。针对IMSI检测,给出了一种分层—二分查找的查找方法,并在...
Using the CallLog Content Provider 318 Using the Browser Content Provider 319 Using the CalendarContract Content Provider 321 Using the UserDictionary Content Provider 321 Using the VoicemailContract...
Android, the next-generation open mobile platform from Google and the Open Handset Alliance, is poised to become a significant player in the mobile device market. The Android platform gives developers...
基于Storm实时统计CallLog实现【可运行】 使用Maven创建项目,引入Storm依赖,编写Storm组件,调试运行 本地集群搭建
Android:实现分页读取手机通讯录联系人信息,并展示给用户。博客地址:https://blog.csdn.net/qq569699973
The ContactsContract and CallLog Providers The CalendarContract Provider The MediaStore Provider Consuming Documents Providing Documents Encrypted Storage Packaging and Distributing Data Advanced ...