文档章节

Android unique_id for android device

当空皓月
 当空皓月
发布于 2017/07/14 14:04
字数 347
阅读 8
收藏 0

Objective:

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

Background:

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.

Existing Approaches:

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.

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();

Drawbacks

It is sim card dependent so

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

  • If there is dual sim then we're dommed

Android_ID:

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

Drawbacks

  • If OS version is upgraded then it may change
  • If device is rooted it gets changed
  • No guarantee that the device_id is unique there are some reports some manufacturers are having duplicate device_id

The WLAN MAC Address

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

Drawbacks

  • If there is no wifi hardware then we're doomed
  • In some new devices If wifi is off then we're doomed.

Bluetooth Address:

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

Drawbacks:

  • if there is no bluetooth hardware we're doomed.
  • In future in some new devices we mightn't able to read it if its off.

Possible solutions:

There are two approaches that I think to solve this problem

  • 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.

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

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

Any help is appreciated !

 

原文地址:https://stackoverflow.com/questions/27233518/perfect-unique-id-for-device-except-imei-android-id-wlan-mac-and-bluetooth-addre

© 著作权归作者所有

共有 人打赏支持
当空皓月
粉丝 13
博文 179
码字总数 67070
作品 0
郑州
不需要任何权限获得Android设备的唯一ID

Is there a unique Android device ID? Android设备有没有唯一的id?如果有的话,我怎么通过java代码获得这个id? 我读了stack OverStack上每一个答案,谷歌的开发者博客和Android文档,我认...

TCTW
2017/10/25
0
0
Dev Guide_Android Basics_Application Fundamenta

(0) Application Fundamentals Android applications are written in the Java programming language. The Android SDK tools compile the code—along with any data and resource files—i......

丁天又
2011/10/14
0
0
[译]Android 安全概述之简介

Android 是一个设计成完全开放的现代的移动平台。Android 应用程序通过使用暴漏给平台的先进的硬件和软件,以及本地和服务的数据,给消费者带来创新和价值。为了保护那价值,这个平台必须提供...

chexEMet
2013/06/25
0
0
Things That Cannot Change

[This post is by Dianne Hackborn, whose fingerprints can be found all over the Android Application Framework — Tim Bray] Sometimes a developer will make a change to an applica......

HCMore
2014/05/23
0
0
[Android官方API阅读]___

学Android不少时间了,项目做的比较少,虽然没找到Android相关的工作,但我仍然不会放弃对Android继续研究的坚持。 准备就看官方文档在抓基础,继续吸收官方的观点跟重点,希望自己能坚持下去...

Endroid
2014/02/26
0
0

没有更多内容

加载失败,请刷新页面

加载更多

马太效应

马太效应

yizhichao
5分钟前
0
0
69.for while循环 continue break exit

20.10 for循环 20.11/20.12 while循环 20.13 break跳出循环 20.14 continue结束本次循环 20.15 exit退出整个脚本 扩展 select用法 http://www.apelearn.com/bbs/thread-7950-1-1.html 20.10......

王鑫linux
14分钟前
0
0
完整的软件开发流程是怎样的

在it圈混迹了这么久,做过各种各样的工作。但是我确一直不知道一个软件从无到有到底是怎么开发的。于是就产生了强烈的好奇心:一个软件产品的结果为什么是这样?为什么开发的速度不能再快一点...

TreasureWe
20分钟前
0
0
深度学习与图像处理之:人像背景虚化

简单实现思路: 对图像内容进行分割,提取人像 对图像背景进行模糊化处理 将人像和背景重新合成 在这里,使用DeepLabV3模型对图像内容进行分割并提取人像,实现的代码如下: import numpy a...

IOTService
23分钟前
0
0
20180918上课截图

小丑鱼00
30分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部