How to get a unique device identifier for Amazon Kindle Fire

To get a unique device identifier on Android phones / tablets, we use the following:

((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId() 

But for the Kindle Fire, we cannot get it.

Any ideas?

+4
source share
2 answers

You should try using the following line:

 deviceId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID); 

This will get the device identifier from the tablet, the code you use only works on phones (it will return null to tablets)

+4
source

put

 <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 

then

try the following:

 public String deviceId; 

then

 // ------------- get UNIQUE device ID deviceId = String.valueOf(System.currentTimeMillis()); // -------- // backup for // tablets etc try { final TelephonyManager tm = (TelephonyManager) getBaseContext() .getSystemService(Main.TELEPHONY_SERVICE); final String tmDevice, tmSerial, tmPhone, androidId; tmDevice = "" + tm.getDeviceId(); tmSerial = "" + tm.getSimSerialNumber(); androidId = "" + android.provider.Settings.Secure.getString( getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode()); deviceId = deviceUuid.toString(); } catch (Exception e) { Log.v("Attention", "Nu am putut sa iau deviceid-ul !?"); } // ------------- END get UNIQUE device ID 

from here β†’ Is there a unique identifier for the Android device?

0
source

Source: https://habr.com/ru/post/1383825/


All Articles