I have two active sim cards on the phone. But getAllCellsInfo returns only one registered cell. How this can happen? And what should I do to fix it?
SubscriptionManager.geAllSubscriptionsInfoList() returns 2 values.
I saw this case when you replacing sim cards on the phone. For example, you can add a second sim card without phone rebooting, and but TelephonyManager continues to provide you the only one registered CellInfo until you reboot the phone.
I'm searching to update data in TelephonyManager without phone restart, programmatically. Is it possible?
When you targeting to Android 10 or higher, you should call requestCellInfoUpdate
val subscriptionManager = getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)
as SubscriptionManager
for (subs in subscriptionManager.activeSubscriptionInfoList) {
val telephonyManager =
(getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager)
.createForSubscriptionId(subs.subscriptionId)
telephonyManager.requestCellInfoUpdate(mainExecutor,
object : TelephonyManager.CellInfoCallback() {
override fun onCellInfo(cellInfo: MutableList<CellInfo>) {
println("updated_cells_count: ${cellInfo.size}")
}
override fun onError(errorCode: Int, detail: Throwable?) {
super.onError(errorCode, detail)
println("updated_cells_error:\n")
detail?.printStackTrace()
}
})
}