android this view's id is no_id,Android unique_id for android device

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 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 !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值