这里的所有答案都在使用managedQuery,现在已弃用。它应该被替换getContext().getContentResolver().query()方法来代替,如提到这里并展示了这里。
这是基于这些示例的简短示例代码:
String[] projection = new String[] {
CallLog.Calls.CACHED_NAME,
CallLog.Calls.NUMBER,
CallLog.Calls.TYPE,
CallLog.Calls.DATE
};
// String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
Cursor cursor = mContext.getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, null, null, null);
while (cursor.moveToNext()) {
String name = cursor.getString(0);
String number = cursor.getString(1);
String type = cursor.getString(2); // https://developer.android.com/reference/android/provider/CallLog.Calls.html#TYPE
String time = cursor.getString(3); // epoch time - https://developer.android.com/reference/java/text/DateFormat.html#parse(java.lang.String
}
cursor.close();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24306 次 |
| 最近记录: |