'How to get globally unique id in Android Studio(for Android OS 11 or higher)?

The answer was simple till the Android 11 version. The answer was 'get MAC address by using the following command'

List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());

After the new MAC address availability changes mentioned here;

https://developer.android.com/training/articles/user-data-ids#mac-11-plus

I can not get the MAC address on a device(I use Android TV devices) which version is 11 or higher. Now I am looking for a new global id for Android Device specific(TVs, tablets, or phones). The id should never change even if the device goes factory reset. How can I achieve that ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source