正文

IMEI

概念

摘自维基百科:

国际移动设备识别码(International Mobile Equipment Identity,IMEI),即通常所说的手机序列号、手机“串号”,用于在行动电话网络中识别每一部独立的手机等行动通讯装置,相当于行动电话的身份证。序列号共有15位数字,前6位(TAC)是型号核准号码,代表手机类型。接著2位(FAC)是最后装配号,代表产地。后6位(SNR)是串号,代表生产顺序号。最后1位(SP)一般为0,是检验码,备用。国际移动设备识别码一般贴于机身背面与外包装上,同时也存在于手机记忆体中,通过输入*#06#即可查询。

代码

获取权限,修改AndroidManifest.xml。

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

样例代码,参考这里:

public static String getIMEI(Context context) {String imei = "";try {TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {return imei;}imei = telephonyManager.getDeviceId();if (imei == null && imei.isEmpty()) {return "";}} catch (Exception e) {e.printStackTrace();}return imei;
}

MAC

概念:

摘自维基百科:

路由器标签上的MAC地址(LAN/WLAN)
MAC地址(英语:Media Access Control Address),直译为媒体访问控制地址,也称为局域网地址(LAN Address),以太网地址(Ethernet Address)或物理地址(Physical Address),它是一个用来确认网络设备位置的地址。在OSI模型中,第三层网络层负责IP地址,第二层数据链接层则负责MAC地址。MAC地址用于在网络中唯一标示一个网卡,一台设备若有一或多个网卡,则每个网卡都需要并会有一个唯一的MAC地址。

代码:

获取权限:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

样例代码,参考这里:

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
String macAddress = wInfo.getMacAddress(); 

SSN(sim卡序列号)

概念:

摘自这里:

Your SIM serial number (SSN), sometimes called the ICC-ID (Integrated Circuit Card ID), is for international identification. The SNN typically has 19 digits and contains specific details about your operator, your location, and when it was made. The first two digits are the telecom ID, the second two digit refer to your country code, the third two digits are the network code, the next four digits are the month and year of manufacturing, the next two digits are the switch configuration code, the next six digits are the SIM number, and the last digit is the check digit.

简单翻译:SIM 序列号,有的时候又被成为ICC-ID(集成电路卡ID),典型的SSN是由19位数字组成的,包含一些运行商、位置信息等。

代码:

获取权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

样例代码:

public static String getSimId (Context context) {TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);String SimSerialNumber = tm.getSimSerialNumber();return SimSerialNumber;
}

IMSI

概念:

摘自这里:

The international mobile subscriber identity or IMSI /ˈɪmziː/ is used to identify the user of a cellular network and is a unique identification associated with all cellular networks. It is stored as a 64 bit field and is sent by the phone to the network. It is also used for acquiring other details of the mobile in the home location register (HLR) or as locally copied in the visitor location register. To prevent eavesdroppers identifying and tracking the subscriber on the radio interface, the IMSI is sent as rarely as possible and a randomly generated TMSI is sent instead.

简单翻译:IMSI,国际移动订户标识,用于标识移动网络的用户,是移动网络的一个唯一的标识。它保存为一个64位的域,由手机发给网络。

代码:

获取权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

样例代码,参考这里:

String IMSI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI); //这种方法还没有确认过,看帖子上说,这个代码google没有暴露出来,需要通过一些技巧去使用

另外一个样例:

private static String getIMSI(Context context) {String imsi = "";try {TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {return imsi;}imsi = telephonyManager.getSubscriberId();if (TextUtils.isEmpty(imsi) || IMSI == imsi) {return imsi;}return imsi;} catch (Exception e) {e.printStackTrace();}return imsi;}

ANDROIDID - 安卓ID

概念:

参考这里:

On Android 8.0 (API level 26) and higher versions of the platform, a 64-bit number (expressed as a hexadecimal string), unique to each combination of app-signing key, user, and device. Values of ANDROID_ID are scoped by signing key and user. The value may change if a factory reset is performed on the device or if an APK signing key changes. For more information about how the platform handles ANDROID_ID in Android 8.0 (API level 26) and higher, see Android 8.0

简单翻译:Android8和更过版本,提供了一个64位的标识符,对于app签名的key、用户和设备是唯一的。

代码:

获取权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

样例代码:

public static String getAndroidId (Context context) {String androidId = Settings.System.getString(context.getContentResolver(), Settings.System.ANDROID_ID);return androidId;
}

Serial Number

概念

参考这里:

A hardware serial number, if available. Alphanumeric only, case-insensitive. For apps targeting SDK higher than Build.VERSION_CODES.O_MR1 this field is set to UNKNOWN.

简单翻译:硬件序列号。

代码:

获取权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

样例代码

public static String getSerialNumber (Context context) {String SerialNumber = android.os.Build.getSerial();return SerialNumber;
}

参考

https://blog.csdn.net/jiangtea/article/details/72889018,这个帖子整理得挺好。
https://blog.csdn.net/aa1733519509/article/details/50053553,这里面有一些样例代码。

Android如何获取唯一ID相关推荐

  1. Unity实现在Android端获取Android手机的唯一ID(设备号)(亲测Android11可用)

    Unity实现在Android端获取Android手机的唯一ID(设备号)(亲测Android11可用) 备注:测试版本Unity2020,理论上Unity2018以上都可用,未做测试 - 文章初衷 ...

  2. Android View 生成唯一 Id

    Android View 生成唯一 Id 可以使用 Hook LayoutInflater 的方法替换 SystemService 原有的 LayoutInflater,在自定义的 LayoutInf ...

  3. [Unity][安卓]unity获取唯一ID,游客登陆

    之前做的时候在网上找了好多有现在整理下一个可以用的 代码段如下 在java中编写 public String GetID(){String serial = null;String m_szDevID ...

  4. Android 获取唯一Id

    git:GitHub - gzu-liyujiang/Android_CN_OAID: 安卓设备唯一标识解决方案,可完全替代移动安全联盟统一 SDK 闭源方案.包括国内手机厂商的开放匿名标识(OAID ...

  5. Android中获取唯一的id

    文章目录 Android唯一设备ID现状 IMEI MAC地址 唯一Id实现方案 那些硬件适合硬件标识 工具类 Android唯一设备ID现状 设备ID,简单来说就是一串符号(或者数字),映射现实中硬 ...

  6. android 获取唯一Id,小小总结一下。仅供参考

    1.获取imei: 前言: 因传统的移动终端设备标识如国际移动设备识别码(IMEI)等已被部分国家认定为用户隐私的一部分, 并存在被篡改和冒用的风险,所以在Android 10及后续版本中非厂商系统应 ...

  7. Android设备获取唯一识别码

    Android系统以及设备都有很多的"标识"号,比如常见的IMEI,SerizalNumber,UUID等概念,但是这些都存在一定程度上的不可靠性,到底如何标记一台Android设 ...

  8. Android10获取唯一ID最佳做法

    官方文档 安卓Q中Google彻底禁止第三发app获取IMEI,WIFI和蓝牙的MAC地址为:02:00:00:00:00:00. 1.使用实例 ID 和 GUID 对于实例 ID 不实用的情况,您还 ...

  9. C# 高并发获取唯一ID算法

    凡事涉及到高性能貌似都是高大上的东西,所以嘛我也试试:其实这个时间戳ID的生成主要为了解决我们公司内部的券号生成,估计有小伙伴认为券号生成有这么麻烦嘛,搞个自增ID完全可以用起来,或者时间取毫微米时间 ...

  10. android设备id完美解决方法,如何在Android中获取唯一的设备硬件ID?

    您可以在下面的链接中查看此博客 [http://android-developers.blogspot.in/2011/03/identifying-app-installations.html] A ...

最新文章

  1. 特征工程(feature engineering)是什么?特征工程(feature engineering)包含哪些方面?
  2. BCH正式升级,智能合约,逐梦而来!
  3. 版本信息文件、虚拟环境创建
  4. 在 word 中 mathType 菜单灰色,无法使用
  5. 迷宫android游戏代码,C++打造迷宫游戏,直接上代码
  6. Linux 进程通信fifo,Linux 进程通信之FIFO的实现
  7. es scroll 时间_游标查询 Scroll | Elasticsearch: 权威指南 | Elastic
  8. SOAWebservice系列课程(1)--The Essentials of Service Orientation
  9. EBS业务学习之应收管理
  10. vb中filecopy拷贝文件
  11. Windows必备软件效率有哪些?
  12. 51Nod 1637 幸运数字转换(思维)
  13. maya前台渲染_maya前台渲染MEL
  14. altium designer设计3D PCB技巧
  15. android仿qq编辑图片,仿QQ图片编辑器 – ImageEditor
  16. 【安装教程】python3.6安装Tensorflow-GPU路上的那些坑(WIN10)
  17. 双系统之删除Linux
  18. 软件开发培训要学多久?怎么学?软件开发培训班多少钱?
  19. Python运算(五)统计statistic模块
  20. PV、UV、UIP、VV、CPC、CPM、RPM、CTR啥意思

热门文章

  1. Oracle RMAN备份与还原
  2. 一图看尽史上三次浏览器大战
  3. 天勤2022数据结构(二)栈和队列
  4. 对抗攻击FGSM的纯粹版FGNS
  5. eclipse最新版本photon下载和安装
  6. Eclipse 性能优化
  7. 论文纠错和管理文献工具
  8. ffmpeg实现摄像头拉流_ffmpeg推流及拉流
  9. 系统分析师论文解答方法
  10. 我们玩游戏,还是游戏玩我们……