Samsung android 6.0 how to get dual sim call logs

2019-04-13 02:37发布

问题:

Samsung(dual sim) before offical android 6.0(not cm) device, I could get call logs with sim slot id, but Samsung(dual sim) android 6.0+ device I get an issue:

String  slotId = cursor.getString(cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID));

<i>slotId</i> = null; but in another device (Huawei mate 8) is work fine

Did samsung modify the com.android.providers.contacts and contacts2.db?

Can someone guide through the solution for this?

回答1:

Update news : I find one solution

  boolean s_bSamsung;
if (Build.VERSION_CODES.M <= Build.VERSION.SDK_INT && s_bSamsung){
   uri = Uri.parse("content://logs/call");
}else {
  uri = Uri.parse(CallLog.Calls.CONTENT_URI);
}

use sim_id find sim slot