Android 获取手机唯一标识(仅限IMEI)
1: 自行导入compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar' 权限的框架
https://github.com/tbruyelle/RxPermissions
直接代码(Koglin):
private fun getImeiNUmber() {
RxPermissions(this).request(Manifest.permission.READ_PHONE_STATE).subscribe() {
if (it) {
val TelephonyMgr = getSystemService(TELEPHONY_SERVICE) as TelephonyManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//28++(8.0)
val IMEI1 = TelephonyMgr.getImei(0)
val IMEI2 = TelephonyMgr.getImei(1)
val MEID = TelephonyMgr.meid
LogUtils.i("设备(28++(8.0))MEID: $IMEI1,$IMEI2,$MEID")
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {//23~27(6.0~7.0)
val MEID &