I know Android SDK is big mess for dual SIM support, but stock dialer shows this information on call log which SIM card ( 1 or 2) was used in a call. I guess it´s stored on call log default database and just want to know if it is possible to retrieve it as simple as possible. I don´t need to know if the SIM is the current one in use. By the way, probably the call log became3s a big mess if you change the Sim cards... but it is another subject and does not matter for me (at the moment ;-)
My questions:
1- Is it possible to get it ?
2- Is it a simple query on the file/database? I found an app which does it called 2SIMCallLogger , available on Google Play.
Does anyone guess how they did it?
I have phone with 2 SIM cards, and I got all fields from calllog, and field names. From results, field named "simid" shows which SIM card handled call.
public void editToFile(){
File file = new File(Environment.getExternalStorageDirectory(), "fileOut.txt");
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(file,true));
writer.write(mEdit.getText().toString());
writer.newLine();
writer.flush();
writer.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
public void getCallLogs(){
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = "DATE DESC";
Cursor cursor = this.getContentResolver().query(Uri.parse("content://call_log/calls"),projection,selection,selectionArgs,sortOrder);
int j=0;
//mEdit is EditText
mEdit.setText("");
if (cursor != null) {
int L=cursor.getColumnCount();
for(int i=0;i<L;i++)
mEdit.append(cursor.getColumnName(i) + "\t");
mEdit.append("\n");
while (cursor.moveToNext()) {
j++;
if(j>=5)
break;
for(int i=0;i<L;i++){
String callField = cursor.getString(i);
mEdit.append(callField + "\t");
}
mEdit.append("\n");
}
}
editToFile();
}
来源:https://stackoverflow.com/questions/16242734/get-the-sim-number-used-on-a-call-through-the-call-log-of-android