安卓获取不到imsi_Android如何获取手机IMSI

董嘉祯
2023-12-01

public static StringgetIMSI(Context context) {

try {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {

return "";

}

if (!PermissionUtil.getInstance().checkPermissions(context, android.Manifest.permission.READ_PHONE_STATE)) {

return "";

}

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

//获取IMSI号

@SuppressLint("MissingPermission") String imsi = telephonyManager.getSubscriberId();

if (null == imsi) {

imsi ="";

}

return imsi;

}catch (Exception e) {

e.printStackTrace();

return "";

}

}

 类似资料: