bHaRaTh bHaRaTh - 6 months ago 35
Android Question

How can I get the UUID of my Android phone in an application?

I'm looking for help to get the UUID of my Android phone. I have searched the net and found one potential solution but it is not working in the emulator.

Here is the code:

Class<?> c;
try {
c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
Log.d("ANDROID UUID",serial);
} catch (Exception e) {

Does anybody know why it isn't working, or have a better solution?


This works for me:

TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String uuid = tManager.getDeviceId();


You also need android.permission.READ_PHONE_STATE set in your Manifest. Since Android M, you need to ask this permission at runtime.

See this anwser :