Get SIM card details through code. Here is full description of all SIM cards.
- Add two permissions in AndroidMenifest.xml file.It is necessary to access phone state and network state.
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- To use Telephone service first of all you need to define it in onCreate() method- MainActivity.java.
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
- Use tm object and find below all functions.
- tm.getLine1Number() - Get SIM card Number
- tm.getSimSerialNumber() - Get SIM Serial Number
- tm.getSimOperatorName() - Get SIM operator name
- tm.getDeviceId() - IMEI Number of device
- tm.getDeviceSoftwareVersion() - Device software Version
- tm.getNetworkCountryIso() - Network Country code
- tm.getNetworkOperator() - SIM Network operator number
- tm.getSubscriberId() - Subscriber Id
- tm.getVoiceMailNumber() - Get VoiceMail Number
- tm.getSimCountryIso() - SIM Country code
- tm.getSimOperator() - SIM Operator name
- tm.isNetworkRoaming() - Check currently your SIM has Roaming service(return boolean)
- tm.getPhoneType() - Phone Type - (return int-> 0-None,1-GSM,2-CDMA,3-SIP,4-Unknown)
- tm.getDataState() - GPRS Status(return int -> 0-disconnected,1-connecting,2-connected,3-Suspended,4-Unknown)
nice and very good! 😎👍
ReplyDelete