Is there reason android.provider.Settings.Secure.ANDROID_ID is return the constant "android_id" instead of a 64-bit number as a hex string ?
Description : android.provider.Settings.Secure.ANDROID_ID
I am using a Samsung Galaxy S4 w /
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="19" />
Cheers
Secure Android ID This value is available via Settings. Secure. ANDROID_ID . It's a 64-bit number that should remain constant for the lifetime of a device.
Secure system settings, containing system preferences that applications can read but are not allowed to write. These are for preferences that the user must explicitly modify through the UI of a system app.
Secure. ANDROID_ID or SSAID) has a different value for each app and each user on the device. Developers requiring a device-scoped identifier, should instead use a resettable identifier, such as Advertising ID, giving users more control. Advertising ID also provides a user-facing setting to limit ad tracking.
The android.provider.Settings.Secure.ANDROID_ID
is a constant that can be used in android.provider.Settings.Secure.getString(ContentResolver resolver, String name)
. By default it is set to 'android_id' since that's the name of the property containing the actual Android ID.
Use this code to get the actual id:
String androidId = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);
android.provider.Settings.Secure.ANDROID_ID is to big so use this answer from: https://stackoverflow.com/a/10151694/1815624
new BigInteger(string, 16).longValue()
For any value of someLong:
new BigInteger(Long.toHexString(someLong), 16).longValue() == someLong
In other words, this will return the long you sent into Long.toHexString()
for any long value, including negative numbers. It will also accept strings that are bigger than a long and silently return the lower 64 bits of the string as a long. You can just check the string length <= 16 (after trimming whitespace) if you need to be sure the input fits in a long.
https://stackoverflow.com/a/10151694/1815624
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With