Android中获取手机中的通话记录还是挺简单的.可以通过content provide来直接获取数据库中的内容...
注:该代码需要用到上下文context..
Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,
null, null, null, null);
if(cursor.moveToFirst()){
do{
CallsLog calls =new CallsLog();
//号码
String number = cursor.getString(cursor.getColumnIndex(Calls.NUMBER));
//呼叫类型
String type;
switch (Integer.parseInt(cursor.getString(cursor.getColumnIndex(Calls.TYPE)))) {
case Calls.INCOMING_TYPE:
type = "呼入";
break;
case Calls.OUTGOING_TYPE:
type = "呼出";
break;
case Calls.MISSED_TYPE:
type = "未接";
break;
default:
type = "挂断";//应该是挂断.根据我手机类型判断出的
break;
}
SimpleDateFormat sfd = new SimpleDateForma