기술참고자료/Android

SIM의 IMSI값 읽어오기

농사꾼봉팔 2011. 4. 19. 16:13
IMSI(International Mobile Subscriber identity)
  1. 전세계적으로 unique한 값(15~18 digits)

  2. MCC(Mobile Country Code) + MNC(Mobile Network Code) + MSIN으로 구성

방법1.


Eclair 버전의
BluetoothHandsfree.java 의  
        parser.register("+CIMI", new AtCommandHandler() {
            @Override
            public AtCommandResult handleActionCommand() {
                // AT+CIMI
                String imsi = mPhone.getSubscriberId();
                if (imsi == null || imsi.length() == 0) {
                    return reportCmeError(BluetoothCmeError.SIM_FAILURE);
                } else {
                    return new AtCommandResult(imsi);
                }
            }
        });

방법2.
String phoneIMSI =
android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);

String phoneIMEI =
 android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMEI);
방법3.
 
TelephonyManager mTelephonyMgr =
                        (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  String imsi = mTelephonyMgr.getSubscriberId();
  String imei = mTelephonyMgr.getDeviceId();
  String phoneNumber = mTelephonyMgr.getLine1Number();