How to find a call log is coming from sim1 or sim2 flutter?

112 views Asked by At

I use this library to get call log in flutter

call_log: ^3.2.1

for (CallLogEntry entry in _callLogEntries) {
      children.add(
        Column(
          children: <Widget>[
            const Divider(),
            Text('F. NUMBER  : ${entry.formattedNumber}', style: mono),
            Text('C.M. NUMBER: ${entry.cachedMatchedNumber}', style: mono),
            Text('NUMBER     : ${entry.number}', style: mono),
            Text('NAME       : ${entry.name}', style: mono),
            Text('TYPE       : ${entry.callType}', style: mono),
            Text('DATE       : ${DateTime.fromMillisecondsSinceEpoch(entry.timestamp)}',
                style: mono),
            Text('DURATION   : ${entry.duration}', style: mono),
            Text('ACCOUNT ID : ${entry.phoneAccountId}', style: mono),
            Text('SIM NAME   : ${entry.simDisplayName}', style: mono),
          ],
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
        ),
      );
    }

How to find a call log is comming from sim 1or sim2

1

There are 1 answers

3
Laxman Magarati On

You can identify the SIM slot using the phoneAccountId property.

  for (CallLogEntry entry in _callLogEntries) {
      String simSlot = "";
      if (entry.phoneAccountId.contains("0")) {
        simSlot = "SIM 1";
      } else if (entry.phoneAccountId.contains("1")) {
        simSlot = "SIM 2";
      }

 children.add(
    Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.start,
      children: <Widget>[
        const Divider(),
        Text('F. NUMBER  : ${entry.formattedNumber}', style: mono),
        Text('C.M. NUMBER: ${entry.cachedMatchedNumber}', style: mono),
        Text('NUMBER     : ${entry.number}', style: mono),
        Text('NAME       : ${entry.name}', style: mono),
        Text('TYPE       : ${entry.callType}', style: mono),
        Text('DATE       : ${DateTime.fromMillisecondsSinceEpoch(entry.timestamp)}',
            style: mono),
        Text('DURATION   : ${entry.duration}', style: mono),
        Text('ACCOUNT ID : ${entry.phoneAccountId}', style: mono),
        Text('SIM SLOT   : $simSlot', style: mono),
      ],
    ),
  );

Here, In the above code, If the phoneAccountId contains the number "0", it is assumed that SIM 1 was used. If it contains the number "1", it is assumed that SIM 2 was used.