0

我正在开发一个应用程序,我想在其中访问 MISSED_CALL 日志。使用下面的代码....

private Cursor getItemsToSync() {
G = "Log method accessing";
ContentResolver r = getContentResolver();

String selections = String.format("%s > ?", CallLog.Calls.DATE,CallLog.Calls.MISSED_TYPE);
String[] selectionArgs = new String[] { String.valueOf(getMaxSyncedDate())};
String sortOrder = SmsConsts.DATE + " LIMIT " + PrefStore.getMaxItemsPerSync(this);
N = CallLog.Calls.CACHED_NAME;
return r.query(Uri.parse("content://call_log/calls"), null,selections,selectionArgs, sortOrder);}

它提供所有通话记录。请建议我如何仅获取 MISSED_CALL 通话记录。提前致谢

4

1 回答 1

2
String[] strFields = {android.provider.CallLog.Calls.CACHED_NAME, android.provider.CallLog.Calls.NUMBER,android.provider.CallLog.Calls.DATE, android.provider.CallLog.Calls.TYPE
    };
    String strOrder = android.provider.CallLog.Calls.DATE + " DESC";

    Cursor mCallCursor = getContentResolver().query(android.provider.CallLog.Calls.CONTENT_URI,strFields, null, null, strOrder);

    if (mCallCursor.moveToFirst()) {

        do {

            boolean missed = mCallCursor.getInt(mCallCursor.getColumnIndex(CallLog.Calls.TYPE)) == CallLog.Calls.MISSED_TYPE;

            if (missed) {

                String name = mCallCursor.getString(mCallCursor
                        .getColumnIndex(CallLog.Calls.CACHED_NAME));

                String number = mCallCursor.getString(mCallCursor
                        .getColumnIndex(CallLog.Calls.NUMBER));
Log.d("PhoneLog", "You have a missed call from " + name + " on " + number // + " at " + time); }

        } while (mCallCursor.moveToNext());

    }
于 2013-06-18T14:31:29.790 回答