文档章节

Android unique_id for android device

当空皓月
 当空皓月
发布于 2017/07/14 14:04
字数 347
阅读 7
收藏 0
点赞 0
评论 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
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
[译]Android 安全概述之简介

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

chexEMet
2013/06/25
0
0
Speeding up Android Emulator on Ubuntu

http://techtach.com/2014/05/boost-android-emulator-performanceon-linux-speeding-up-android-emulator-on-ubuntu/ Note: Earlier I had asked this question on stackoverflow , but got......

cyper
2014/12/13
0
0
Android learning - Activities

Android provides a number of ready-made views that you can use to design and organize your layout. "Widgets" are views that provide a visual (and interactive) elements for the s......

方传云
2012/03/04
0
0
Dev Guide_Android Basics_Application Fundamentals

(2) That covers the basics regarding how an Android application exists within the system. The rest of this document introduces you to: The core framework components that define ......

丁天又
2011/11/01
0
0
[Android官方API阅读]___

Device Compatibility Android is designed to run on many different types of devices, from phones to tablets and televisions. As a developer, the range of devices provides a huge ......

Endroid
2014/02/27
0
0
under ubuntu, using usb and adb connect device

添加usb支持,使linux系统认识这个Vendor。 Create a new udev rule file under the PC's /etc/udev/rules.d/ named: imx-android.rules. And fill in the following line into the file: SU......

eric_zhang
2012/02/12
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

OSChina 周一乱弹 —— 如果是你喜欢的女同学找你借钱

Osc乱弹歌单(2018)请戳(这里) 【今日歌曲】 @guanglun :分享Michael Learns To Rock的单曲《Fairy Tale》 《Fairy Tale》- Michael Learns To Rock 手机党少年们想听歌,请使劲儿戳(这...

小小编辑
39分钟前
9
3
NNS域名系统之域名竞拍

0x00 前言 其实在官方文档中已经对域名竞拍的过程有详细的描述,感兴趣的可以移步http://doc.neons.name/zh_CN/latest/nns_protocol.html#id30 此处查阅。 我这里主要对轻钱包开发中会用到的...

暖冰
今天
0
0
32.filter表案例 nat表应用 (iptables)

10.15 iptables filter表案例 10.16/10.17/10.18 iptables nat表应用 10.15 iptables filter表案例: ~1. 写一个具体的iptables小案例,需求是把80端口、22端口、21 端口放行。但是,22端口我...

王鑫linux
今天
0
0
shell中的函数&shell中的数组&告警系统需求分析

20.16/20.17 shell中的函数 20.18 shell中的数组 20.19 告警系统需求分析

影夜Linux
今天
0
0
Linux网络基础、Linux防火墙

Linux网络基础 ip addr 命令 :查看网口信息 ifconfig命令:查看网口信息,要比ip addr更明了一些 centos 7默认没安装ifconfig命令,可以使用yum install -y net-tools命令来安装。 ifconfig...

李超小牛子
今天
1
0
[机器学习]回归--Decision Tree Regression

CART决策树又称分类回归树,当数据集的因变量为连续性数值时,该树算法就是一个回归树,可以用叶节点观察的均值作为预测值;当数据集的因变量为离散型数值时,该树算法就是一个分类树,可以很...

wangxuwei
昨天
1
0
Redis做分布式无锁CAS的问题

因为Redis本身是单线程的,具备原子性,所以可以用来做分布式无锁的操作,但会有一点小问题。 public interface OrderService { public String getOrderNo();} public class OrderRe...

算法之名
昨天
11
0
143. Reorder List - LeetCode

Question 143. Reorder List Solution 题目大意:给一个链表,将这个列表分成前后两部分,后半部分反转,再将这两分链表的节点交替连接成一个新的链表 思路 :先将链表分成前后两部分,将后部...

yysue
昨天
1
0
数据结构与算法1

第一个代码,描述一个被称为BankAccount的类,该类模拟了银行中的账户操作。程序建立了一个开户金额,显示金额,存款,取款并显示余额。 主要的知识点联系为类的含义,构造函数,公有和私有。...

沉迷于编程的小菜菜
昨天
1
0
从为什么别的队伍总比你的快说起

在机场候检排队的时候,大多数情况下,别的队伍都要比自己所在的队伍快,并常常懊悔当初怎么没去那个队。 其实,最快的队伍只能有一个,而排队之前并不知道那个队快。所以,如果有六个队伍你...

我是菜鸟我骄傲
昨天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部