是否有一个顺利的方式来获得一个手机塔的eNB id在Android工作室?



我是android应用程序开发的新手,目前正在尝试使用Kotlin在android Studio中获得eNB。我知道这个解决方案:如何在Android Studio (TelephonyManager)上获得LTE的eNB id

然而,如果我尝试实现这一点,我的应用程序只是崩溃,我没有得到任何反馈。在设置应用程序以获取移动手机数据时,您需要记住什么特别的事情吗?

谢谢!

从Telephony_Service初始化TelephonyManager,并通过过滤不同的移动网络标准,如UMTS (3G), LTE (4G)或NR (5G),并使用"getallCellInfo方法,您可以从您的手机当前连接的手机获取所有相关信息。下面是代码:

val tm = getSystemService(TELEPHONY_SERVICE) as TelephonyManager
val cellInfo = tm.allCellInfo
if(cellInfo != null){
for(info in cellInfo){
if(info is CellInfoLte){
val identityLte = info.cellIdentity
val operator = identityLte.operatorAlphaLong.toString()
// get more Information like mcc, mnc, pci, tac, ... //
}
}
}

最新更新