How to get CID and LAC for Both Sim in case of dual sim mobile Programmatically?

460 Views Asked by At

I am working on a project in which I have to track location using the mobile tower. When sim2 is on emergency it is giving null pointer exception in Telephony Manager. I have to get LAC, CID, MCC, MNC for both sims. I can get MCC, MNC by using SubscriptionManager. But how can I get LAC and MCC for both sim cards?

1

There are 1 best solutions below

0
On

Try this way

Create a pojo lets say Operator

data class Operator(
    var operatorName: String? = null,
    var operatorNumber: String? = null,
    var position: Int? = null,
    var subscriptionId: String? = null,
    var subId: Int? = null)

Now in Activity

var subscriptionManager =getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
        val listOfSubInfo = subscriptionManager.activeSubscriptionInfoList
        for (value in listOfSubInfo) {
                operatorList?.add(Operator(value.displayName.toString(), value.number, value.simSlotIndex, value.iccId, value.subscriptionId))
          }

You now have list of all sims info inside device. You can get MCC, MNC ,subscriptionId,iccId using this method .