Favolas
Favolas

Reputation: 7243

Detect SIM card change on Android Q 10

There are many of questions/answers on how to detect if the user as changed or not is SIM but many of them rely on obtaining the SIM card imsi (TelephonyManager.getSubscriberId()) and since this info is no longer available (https://developer.android.com/about/versions/10/privacy/changes#non-resettable-device-ids), on Android Q/10 how can we detect that the user changed is SIM?

Upvotes: 10

Views: 3231

Answers (1)

Paweł Szymański
Paweł Szymański

Reputation: 336

Check this mobile service subscriptions. Based on the given description, every new sim card should receive a new int number SubscriptionId, unique per device, until it gets factory reset.

var subscriptionManager = getSystemService(SubscriptionManager::class.java)
subscriptionManager.getActiveSubscriptionInfoList()
SubscriptionInfo.getSubscriptionId()

Upvotes: 2

Related Questions