Fixed and unique value in Android in Unity 3D

2

I'm having difficulty getting a single, fixed value in C #, so I need to get a value like this, for security reasons in my software.

I have tried using SystemInfo.deviceUniqueIdentifier , but unfortunately when turning off the wifi of the device this value changes, the same in Windows if you connect any device to USB it will change too.

In Windows I solved the problem by taking the physical number of the HD.

I have tried the IMEI but it only works on devices that have telephony chip support.

How do I get this value on Android?

    
asked by anonymous 24.08.2015 / 18:29

2 answers

0

Thanks, I ended up finding that way too, apparently it worked, but I'm testing on various devices here to see if this solution is stable.

 AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");

 AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject> ("currentActivity");

 AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject> ("getContentResolver");

 AndroidJavaClass secure = new AndroidJavaClass ("android.provider.Settings$Secure");


 string android_id = secure.CallStatic<string> ("getString", contentResolver, "android_id");
    
24.08.2015 / 20:16
2

According to this response in OS each system has its form. On Android the suggested way is:

android.telephony.getDeviceId()
    
24.08.2015 / 18:33