开发者

How to get a number from the Call log and use it to save to an Object - Android

From the android device i do need to select a number from the CAll L开发者_运维问答og and use it to set in my own object . I am looking at CallLog.Calls but only outgoing is provided?


I use the following to query the Call Log.

    final String[] projection = null;
    final String selection = null;
    final String[] selectionArgs = null;
    final String sortOrder = "DATE DESC";
    Cursor cursor = _context.getContentResolver().query(
            Uri.parse("content://call_log/calls"),
            projection,
            selection,
            selectionArgs,
            sortOrder);
    if (cursor != null) {
        //Loop through the call log.
        while (cursor.moveToNext()) { 
            //Common Call Log Items
            String callNumber = cursor.getString(cursor.getColumnIndex(
                                    android.provider.CallLog.Calls.NUMBER));
            String callDate = cursor.getString(cursor.getColumnIndex(
                                    android.provider.CallLog.Calls.DATE));
            String callType = cursor.getString(cursor.getColumnIndex(
                                    android.provider.CallLog.Calls.TYPE));
            String isCallNew = cursor.getString(cursor.getColumnIndex(
                                    android.provider.CallLog.Calls.NEW));
            //DO YOUR WORK HERE...
        }
    }

I hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜