文档章节

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

© 著作权归作者所有

共有 人打赏支持
当空皓月
粉丝 14
博文 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开发教程:蓝牙测试

软件平台:Windows 7 + Eclipse + SDK 设计思路: 配合倒计时定时器实现蓝牙打开,可见,扫描三个功能 源代码: main.xml: xml version="1.0" encoding="utf-8"?> TextView> Button> LinearLayout......

长平狐
2012/09/03
352
0

没有更多内容

加载失败,请刷新页面

加载更多

图像库stb_image

https://github.com/nothings/stb 目前一般主流的图像格式也就是bmp,jpg,png,tga,dds,除了DDS一般是给DX用的,虽然一堆OpenGL程序也有用的,但是我一般只用png和tga, png不用说了,带a...

robslove
25分钟前
1
0
Spring 事务提交回滚源码解析

前言 在上篇文章 Spring 事务初始化源码分析 中分析了 Spring 事务初始化的一个过程,当初始化完成后,Spring 是如何去获取事务,当目标方法异常后,又是如何进行回滚的,又或是目标方法执行...

TSMYK
44分钟前
2
0
百度黄埔学院将培养一批首席AI架构师,为“国之重器”赋能

深度学习高端人才不仅是AI发展的重要养分,也是企业转型AI巨大推动力。2019年1月19日,百度黄埔学院——深度学习架构师培养计划在百度科技园举行开学典礼,深度学习技术及应用国家工程实验室...

深度学习之桨
今天
3
0
扒站wget仿站

wget -c -r -p -np -k http://xxx.com/xxx 其中: -c, --continue (断点续传) 接着下载没下载完的文件 -r, --recursive(递归) specify recursive download.(指定递归下载) -p, --page...

临江仙卜算子
今天
2
0
Nextjs+React非页面组件SSR渲染

@随风溜达的向日葵 Nextjs Nextjs是React生态中非常受欢迎的SSR(server side render——服务端渲染)框架,只需要几个步骤就可以搭建一个支持SSR的工程(_Nextjs_的快速搭建见Next.js入门)...

随风溜达的向日葵
今天
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部