How to get SIM1 or SIM2 from call logs programatically

869 Views Asked by At

In my application I need to display call log as sim1 or sim2.
I am able to get number, name,incoming or outgoing and time stamp, but I'm unable to retrieve which sim card slot is used.

I'm using the following code:

  Uri callUri = Uri.parse("content://call_log/calls");
  String strOrder = CallLog.Calls.DATE + " DESC";

  Cursor cursor_call_logs = getContentResolver().query(callUri, null,null, null,strOrder);

  while (cursor_call_logs.moveToNext()) {
     String num = cursor_call_logs.getString(cursor_call_logs.getColumnIndex(CallLog.Calls.NUMBER));
     String name = cursor_call_logs.getString(cursor_call_logs.getColumnIndex(CallLog.Calls.CACHED_NAME));
     String duration = cursor_call_logs.getString(cursor_call_logs.getColumnIndex(CallLog.Calls.DURATION));
     int type = Integer.parseInt(cursor_call_logs.getString(cursor_call_logs.getColumnIndex(CallLog.Calls.TYPE)));
     String callDate = cursor_call_logs.getString(cursor_call_logs
                                        .getColumnIndex(CallLog.Calls.DATE));

    Log.e("VIA_NUMBER", "val@@ " + cursor_call_logs.getColumnIndex("VIA_NUMBER"));
    Log.e("normalized_number", "val@@ " + cursor_call_logs.getColumnIndex("normalized_number"));
    Log.e("subscription_id", "val@@ " + cursor_call_logs.getColumnIndexOrThrow("subscription_id"));

How can I retrieve which sim card slot was used for the phone call.

0

There are 0 best solutions below