UNIQUE_ID完美的设备,除了IMEI,Android_ID,WLAN Mac和蓝牙地址 [英] Perfect unique_id for device except IMEI,Android_ID,WLAN Mac and Bluetooth address

查看:159
本文介绍了UNIQUE_ID完美的设备,除了IMEI,Android_ID,WLAN Mac和蓝牙地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方式来找出的 UNIQUE_ID 作为Android设备。

I am looking for a way to find out a unique_id for android device.

我会使用ID的登录请求负载并作为我的应用程序的许可基于服务的应用程序的标识不应在正常情况下更改。

I will use the Id in login request payload and as my app is license based service app the Id should not change under normal circumstances.

在iOS的有一些为iOS <一个唯一的ID解决方案href="https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFUUIDRef/index.html">CFUUID identifierForVendor 再加上的钥匙扣,广告标识等,可以做这个工作高达期望。

In iOS there are some unique id solutions for iOS such as CFUUID or identifierForVendor coupled with Keychain,Advertising Identifier etc.. that can do this job upto the expectation.

但在Android的一切,我知道的选项似乎有洞了。

But in Android all the options that I know seems to have hole in it.

IMEI:

TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String m_deviceId = TelephonyMgr.getDeviceId();

缺点

这是SIM卡的依赖等等

It is sim card dependent so

  • 如果没有SIM卡,那么我们注定

  • If there is no sim card then we're doomed

如果有双卡那么我们dommed

If there is dual sim then we're dommed

Android_ID:

  String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

缺点

  • 如果操作系统版本的升级,它可能会改变
  • 如果设备是植根它被改变了
  • 在不能保证DEVICE_ID是唯一的有一些报道,有些制造商有重复的DEVICE_ID

的WLAN MAC地址

WifiManager m_wm = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
String m_wlanMacAdd = m_wm.getConnectionInfo().getMacAddress();

缺点

  • 如果没有WIFI硬件那么我们注定
  • 在一些新的设备如果WiFi是关闭那么我们就注定要失败。

蓝牙地址:

   BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
   String m_bluetoothAdd = m_BluetoothAdapter.getAddress();

缺点:

  • 如果没有我们注定蓝牙硬件。
  • 在未来一些新的设备,我们可能不能够如果它的关闭。
  • 阅读

有两种方法,我认为要解决这个问题

There are two approaches that I think to solve this problem

  • 我们生成一个随机ID通过散列时间戳与我所提到的唯一ID和登录过程,以便在下一次保存它,我们会检查,如果关键的存储值为null如果这样的话,我们就会产生并将其存储否则我们将使用关键字的值。

  • We generate a random id by hashing timestamp with unique ids that I have mentioned and store it so next time during login we’ll check if the the stored value of key is null if its so then we’ll generate and store it else we’ll use the value of the key.

如果有什么等价于 钥匙扣的iOS的话,我们是很好的这种做法。

If there is something equivalent to keychain of iOS then we’re good with this approach.

查找全局标识符类似的 advertisingIdentifier 的iOS是相同的设备中所有的应用程序。

Find a global identifier something like advertisingIdentifier of iOS which is same for all the apps in the device.

任何帮助是AP preciated!

Any help is appreciated !

推荐答案

我选择使用的 Android_ID 的,因为它不依赖于任何硬件。

I have chosen to use Android_ID since It's not dependent on any hardware.

Build.SERIAL 的还依赖于的电话的是在无线设备只的这个Build.SERIAL是行不通的可用性。

Build.SERIAL also dependent on availability of telephony that is in wifi only devices this Build.SERIAL won't work.

我已经解释了如何其他方式都依赖于的的硬件可用性的在问题本身。

I have explained how other approaches are dependent upon the hardware availability in the question itself.

这篇关于UNIQUE_ID完美的设备,除了IMEI,Android_ID,WLAN Mac和蓝牙地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆