文档章节

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官方API阅读]___

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

Endroid
2014/02/26
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 安全概述之简介

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

chexEMet
2013/06/25
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Vue- 对象语法 v-bind:class与对象语法的使用

我们可以传给 v-bind:class 一个对象,以动态地切换 class 。 <div v-bind:class="{ active: isActive }"></div>//对象语法也就是在v-bind:class绑定一个对象的时候,里面的值将影响最终取值...

文文1
19分钟前
1
0
epoll中使用

1、一个线程epoll_wait时,另一个线程调用epoll_ctl是安全的。 2、使用edge触发,在socket有数据到来后,不收取数据,再次调用epoll_ctl将socket加入,仍会触发下一次动作。 asio用该方法来发...

gelare
47分钟前
1
0
PHP规范PSR2

PSR标准 - PSR-2 为了尽可能的提升阅读其他人代码时的效率,下面例举了一系列的通用规则,特别是有关于PHP代码风格的。 各个成员项目间的共性组成了这组代码规范。当开发者们在多个项目中合作...

geek土拨鼠
今天
5
0
【极简】如何在服务器上安装SSL证书?

本文适合任何人了解,图形化操作。下面以腾讯云为例,并且服务器(linux)也安装了宝塔面板。 1.登陆腾讯云账号进入控制台,找到SSL的产品 2.按要求申请并填写表单,记住私钥密码 3.提交后,待...

皇冠小丑
今天
1
0
深入理解编译器

深入理解编译器 原文出处 欢迎向Rust中文社区投稿,投稿地址,好文将在以下地方直接展示 1 Rust中文社区首页 2 Rust中文社区Rust文章栏目 3 知乎专栏Rust语言 编程语言是如何工作的 从内部理解...

krircc
今天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部