Starting on API Level 22, there is native support in Android for Dual-SIM devices. At the center of the APIs, there is SubscriptionInfo.getSubscriptionId()
.
Using these IDs, you can retrieve SmsManager
s for each respective SIM card to send SMS and MMS. You can also identify through which SIM card an SMS was received on the SMS_RECEIVED_ACTION
, and so on.
However, what is the lifetime of a Subscription ID? Can I store a Subscription ID in a local database and count on it to still be valid and pointing to the same SIM card later? By later, I mean after rebooting the device, removing its SIM card and popping it back in, or even after factory resetting the device.
I tested the resilience of SubscriptionId
myself, using two SIM cards, though on a Single-SIM device, since that is what I had available at the time.
First, I noted the SubscriptionId
the system was giving me when SIM Card A was inserted. The SubscriptionId
I was getting had a value of 2
.
Next, I restarted the device. The SubscriptionId
after restart was still 2
.
Then, I turned off the device, removed SIM Card A and put in SIM Card B. After turning the device back on, the SubscriptionId
changed to 4
.
Lastly, I turned the device back off, removed SIM Card B and put SIM Card A back in. After turning the device back on, the SubscriptionId
changed back to 2
.
In conclusion, it looks like Android assigns a SubscriptionId
unique to each SIM Card. The SubscriptionId
seems to survive system reboots, and SIM Card removal and reinsertion. I did not test factory resets, but my gut feeling is that it probably will not survive those, since the system would not have any history of interaction with a SIM Card after a factory reset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With