比思論壇
標題:
Android中查询所有的通话记录
[打印本頁]
作者:
我是谁我爱谁啊
時間:
2016-4-16 12:12
標題:
Android中查询所有的通话记录
public List<CallRecord> queryCallLog() {
ContentResolver resolver = context.getContentResolver();
List<CallRecord> list = new ArrayList<CallRecord>();
//呼叫记录的URI CallLog.Calls.CONTENT_URI
//Uri uri = Uri.parse("CallLog.Calls.CONTENT_URI");
Cursor cursor = resolver.query(CallLog.Calls.CONTENT_URI, null, null, null, null);
while(cursor.moveToNext()){//查询到了呼叫记录
CallRecord call = new CallRecord();
number = cursor.getString(cursor.getColumnIndex("Calls.NUMBER"));
String date = cursor.getString(cursor.getColumnIndex("Calls.DATE"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date d = new Date(Long.parseLong(date));
String time = sdf.format(d);
call.setDate(time);
call.setNumber(number);
list.add(call);
}
//return list;
作者:
winoy
時間:
2016-9-26 23:52
技术贴啊,谢谢了
作者:
winoy
時間:
2016-9-26 23:54
找好久了,真有用
歡迎光臨 比思論壇 (http://bb-cdn.shop/)
Powered by Discuz! X2.5