Programmatically retrieve IMEI number for dual SIM in android

后端 未结 12 1139
一生所求
一生所求 2020-12-05 15:19

For single SIM following code works:

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei= tm.getDeviceId();
12条回答
  •  粉色の甜心
    2020-12-05 16:03

    You can IMEI in Android O or above.

    Set deviceIdList = new HashSet<>();
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    int phoneCount = telephonyManager.getPhoneCount();
    for (int i = 0; i < phoneCount; i++) {
       deviceIdList.add(telephonyManager.getImei(i));
    }
    

提交回复
热议问题