简体   繁体   English

在双SIM卡移动编程的情况下,如何为两个SIM卡获取CID和LAC?

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

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. sim2紧急情况下,它将在Telephony Manager中提供空指针异常。 I have to get LAC, CID, MCC, MNC for both sims. 我必须同时获得两个模拟人生的LAC,CID,MCC,MNC。 I can get MCC, MNC by using SubscriptionManager. 我可以使用SubscriptionManager获得MCC,MNC。 But how can I get LAC and MCC for both sim cards? 但是,如何获得两个SIM卡的LAC和MCC?

Try this way 试试这个

Create a pojo lets say Operator 创建一个pojo可以说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 . 您可以使用此方法获取MCC,MNC,subscriptionId,iccId。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM