How to find the device ID or Serial Number of an android device?
Here is a simple API to find the device ID of an android device.
There are many ways to get the device ID in android
String serial_no = null;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial_no = (String) get.invoke(c, "ro.serialno");
System.out.println("Device serial ID : " + serial_no);
} catch (Exception e) {
System.out.println("Some error occured : " + e.getMessage());
}
Note : Try this in a real device, then only you will get the device ID.
Also put this permission in the AndroidManifest file
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
Link to this post!