我想使用此代碼來獲取在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