我想使用此代码来获取在android通话记录所有来电:查询Android上的通话记录跳过第一个记录
ArrayList<Call> list = new ArrayList<Call>();
Cursor cursor;
// The fields we want to select from the internal database. Setting this
// to null is equivalent to * (e.g., SELECT * FROM...)
String[] projection = {CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.TYPE};
String sortOrder = CallLog.Calls.DATE + " desc";
int numberCol = 0;
String contactName;
String contactNumber;
String contactDate;
int callType;
Call phone_call;
// Query the CallLog table, selecting only the number and date then sorting it by the date.
cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, null, null, sortOrder);
numberCol = cursor.getColumnIndex(CallLog.Calls.NUMBER);
if(cursor.moveToFirst()) {
while(cursor.moveToNext()) {
//do stuff
}
}
cursor.close();
return list;
这工作,对于大多数呼叫,除了最上面的一个(最新,因为我按日期排序,降序)。
这怎么可能?
谢谢!删除第一行,现在它的作品 – user3287740