Unique identifier android device

Asked

Viewed 2,007 times

0

I have the following problem in my application. At first boot I capture androidID using the following method:

 Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)

This code is being used to validate on a web service if it is the first installation of the application on a given device.

But when performing an android system update, or giving a Recovery in it this code is generated again, the Google documentation says that it is updated whenever the first system boot is done.

I need a code that’s unique and can’t be the IMEI because it doesn’t exist on devices that don’t have a chip.

Any suggestions?

  • I can not fully visualize your problem, but could not be a registration where the user inform the email? This email is unique in your registration.

  • Opa, I can not use the email because the device can be used by several users, and so catch with user and password. I need an ID because the system is charged for copies, at the time of the first registration I take a series of data from the device and send to the webservice and until then I thought that Androidid was unique and immutable, but today I found that it changes, with this the device is re-registered and decreases the number of copies of the user.

  • Have you looked here? Lots of information. http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id

  • I already had a look and I will look again. Thanks.

  • Cannot be ID registered by GCM / FCM?

  • I decided using NETWORK CARD MACADRESS. Thank you all.

Show 1 more comment

2 answers

2

Well, unique ID on Android is a little tricky to be sure, there are several places that provide an ID and not always the same place is available on all devices, my solution was to create a ID of my own combining all the information I can get.

I use this to control access and honestly never had problem to change (however, it may change if the phone is formatted or change yes), so, I believe it is ideal at first access to write this ID in a bank on mobile (that would not change if I change the SIM), in this case, would only lose the ID if it formatted the phone, which would also trigger a first installation.

Follow the code I use:

 final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, 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());
    String deviceId = deviceUuid.toString();

This code will generate an ID in this format: 00000000-5ff5-17e8-ffff-ffff9d6a7f8f

  • I decided using NETWORK CARD MACADRESS. Thank you all.

  • If the answer helped you, or you found pertinent to the question, please mark it as an answer :)

1

Build class has some identifiers that can help.

This class brings information about the current build, extracted from the system properties.

Example of build information taken from a device:

Build.ID: QQ1D.200105.002

Build.USER: genymotion

Build.VERSION.RELEASE: 10

Build.Time: 1591957173000

Build.Host: 8cb93f10a5dd

Build.Hardware: vbox86

Code example:

String id = Build.ID + Build.USER + Build.VERSION.RELEASE + Build.TIME + Build.HOST + Build.HARDWARE;
System.out.println(id);
//output: QQ1D.200105.002genymotion1015919571730008cb93f10a5ddvbox86

There are other variables in the Build class that I didn’t say here, in case you want to know more:Build Class(Android OS)

Gathering building class information can generate a unique identifier for you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.