我想提取未接来电,分别收到sim1或sim2的通话记录。我想区分不同SIM卡的通话记录。 我已经尝试过已经提取的总通话记录,但我无法区分双SIM卡环境中的SIM卡插槽。
这是我尝试过的:
StringBuffer sb = new StringBuffer();
Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null,null, null, null);
int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);
int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
sb.append("Call Details :");
while (managedCursor.moveToNext()) {
String phNumber = managedCursor.getString(number);
String callType = managedCursor.getString(type);
String callDate = managedCursor.getString(date);
Date callDayTime = new Date(Long.valueOf(callDate));
String callDuration = managedCursor.getString(duration);
String dir = null;
int dircode = Integer.parseInt(callType);
switch (dircode) {
case CallLog.Calls.OUTGOING_TYPE:
dir = "OUTGOING";
break;
case CallLog.Calls.INCOMING_TYPE:
dir = "INCOMING";
break;
case CallLog.Calls.MISSED_TYPE:
dir = "MISSED";
break;
}
sb.append("\nPhone Number:--- " + phNumber + " \nCall Type:--- "
+ dir + " \nCall Date:--- " + callDayTime
+ " \nCall duration in sec :--- " + callDuration);
sb.append("\n----------------------------------");
Log.d(TAG_NAME,"\nPhone Number:--- " + phNumber + " \nCall Type:--- "
+ dir + " \nCall Date:--- " + callDayTime
+ " \nCall duration in sec :--- " + callDuration);
count++;
}
managedCursor.close();
Log.d(TAG_NAME,"Total Call Log count is "+count);
return sb.toString();
答案 0 :(得分:0)
使用SUB_ID常量值获取有关SIM插槽的信息。
/**
* The subscription ID used to place this call. This is no longer used and has been
* replaced with PHONE_ACCOUNT_COMPONENT_NAME/PHONE_ACCOUNT_ID.
* For ContactsProvider internal use only.
* <P>Type: INTEGER</P>
*
* @Deprecated
* @hide
*/
public static final String SUB_ID = "sub_id";
用作CallLog.Calls.SUB_ID =“sub_id”