imei生成 java_Android UUID生成(IMEI、设备序列号、MAC地址)

当前位置:

IT大杂烩

>

JavaScript

> Android UUID生成(IMEI、设备序列号、MAC地址)

Android UUID生成(IMEI、设备序列号、MAC地址)

www.someabcd.com  网友分享于:Jun 8, 2018 9:29:04 AM

根据手机设备的IMEI、设备序列号、MAC地址经过MD5加密,得到手机专有的序号; import android.content.Context;import android.net.wifi.WifiInfo;import android.net.wifi.WifiManager;import android.os.Build;import android.telephony.TelephonyManager;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Formatter;public class Utils{ public Utils() { } public static final String generateUUID(Context context) { String s = ((TelephonyManager)context.getSystemService("phone")).getDeviceId(); if(s == null) s = ""; String s1 = android.provider.Settings.Secure.getString(context.getContentResolver(), "android_id"); if(s1 == null) s1 = ""; String s2; String s3; WifiInfo wifiinfo; String s4; if(android.os.Build.VERSION.SDK_INT >= 9) { s2 = Build.SERIAL; if(s2 == null) s2 = ""; } else { s2 = getDeviceSerial(); } s3 = ""; wifiinfo = ((WifiManager)context.getSystemService("wifi")).getConnectionInfo(); if(wifiinfo != null) { s3 = wifiinfo.getMacAddress(); if(s3 == null) s3 = ""; } try { s4 = getMD5String((new StringBuilder()).append(s).append(s1).append(s2).append(s3).toString()); } catch(NoSuchAlgorithmException nosuchalgorithmexception) { nosuchalgorithmexception.printStackTrace(); return null; } return s4; } private static final String getDeviceSerial() { String s; try { Method method = Class.forName("android.os.Build").getDeclaredMethod("getString", new Class[] { Class.forName("java.lang.String") }); if(!method.isAccessible()) method.setAccessible(true); s

发布此文章仅为传递网友分享,不代表本站观点,若侵权请联系我们删除,本站将不对此承担任何责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值