How to get information about the second sim in android

Using this method below, I get information about sim one

TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); // Get the SIM country ISO code String simCountry = telephonyManager.getSimCountryIso(); Log.e("Show:", simCountry); // Get the operator code of the active SIM (MCC + MNC) String simOperatorCode = telephonyManager.getSimOperator(); Log.e("Show:", simOperatorCode); // Get the name of the SIM operator String simOperatorName = telephonyManager.getSimOperatorName(); Log.e("Show:", simOperatorName); // Get the SIM's serial number String simSerial = telephonyManager.getSimSerialNumber(); Log.e("Show:", simSerial); // Get the phone number String mPhoneNumber = telephonyManager.getLine1Number(); Log.e("Show:", mPhoneNumber); 

how to get information about the second sim dual sim phone?

  // Get the phone number String mPhoneNumber = telephonyManager.getLine1Number(); Log.e("Show:", mPhoneNumber); 

work on some device

Resolution:

 <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

So what should I do? Is there a mistake?

+5
source share
1 answer

From Android API 22 SubscriptionManager is available You just need to call

SubscriptionManager.from(context).getActiveSubscriptionInfo(1)

to get information about the second sim card

0
source

Source: https://habr.com/ru/post/1235119/


All Articles