Fixed and unique value on Android in Unity 3D

Asked

Viewed 85 times

3

I’m having trouble getting a unique and fixed value in C#, I need to get a value like this, for security reasons of my software.

I’ve tried using the SystemInfo.deviceUniqueIdentifier, but unfortunately when turning off the wifi device this value changes, same in Windows in case you connect any device on USB it will change also.

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

I tried the IMEI but only works on devices that support chip telephone.

How to get this value on Android?

2 answers

2

  • the link seems wrong.

  • @Alanvargas, apparently this call suggested by the bigown is encapsulated in Unity by SystemInfo.deviceUniqueIdentifier which you already use. Have a look at the documentation: http://docs.unity3d.com/ScriptReference/SystemInfo-deviceUniqueIdentifier.html

1


Thanks, I ended up finding this way also that apparently 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");

Browser other questions tagged

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