How to read device information in Android 10?

1.6k views Asked by At

I am trying to read device Information like Build.SERIAL and DeviceId with TelephonyManager. In Android 9 and below I was able to access all this information without any Issue.

I am receiving following exception when I try to read Device info in Android 10

GetDeviceId: the user 10727 do not meet the requirement to access device identifies.

This information is very important for my app's security. I need way to identify device with non-changeable device identity.

1

There are 1 answers

1
Pavel B. On

As stated here it is one of the changes introduced in android 10: https://developer.android.com/about/versions/10/highlights

You should try to use one of the best practices here: https://developer.android.com/training/articles/user-data-ids

Anyway, based on my experience, if You are getting a UUID inside Your app, You will get the same uuid even if Your app is uninstalled and reinstalled again. Note, that this uuid is not actual device uuid on newer Android devices. But still, if You store it on your server, it can be usable to detect uninstall and reinstall.

Settings.Secure.getString(App.instance.getContentResolver(), Settings.Secure.ANDROID_ID);