I want to get call log history by sim slot number. Like this image:
For that I searched many sites till I got:
Cursor managedCursor = getActivity().managedQuery(CallLog.Calls.CONTENT_URI, null,
null, null, strOrder);
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);
int account = 0;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
account = managedCursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_COMPONENT_NAME);//for versions above lollipop
ac_id = managedCursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID);
}
Currently getting PHONE_ACCOUNT_COMPONENT_NAME and PHONE_ACCOUNT_ID as per the android documentation but how to use it to get sim slot
Followed this links :
Samsung android 6.0 how to get dual sim call logs with sim slot id?
Get calls from log by specific SIM
How to get carrier name from dual sim phone Android?
Programmatically retrieve IMEI number for dual SIM in android
but none of them worked for me.
I got the names of both current sim in dual sim in api>21 using SubscriptionManager Class but unable to check it in call log.
Kindly suggest me better way to do that.