How To Get Real Serial Number Of Lenovo Tab In Android
I am trying to get the serial number of my Lenovo Idea Tab running Android. I tried all the options available in Google search, which are: Class c = Class.forName('android
Solution 1:
I recently had to also get the SN for a lenovo tablet. You can use the following methods
publicstaticStringgetIMEI(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager != null ? (telephonyManager.getDeviceId() != null ? telephonyManager.getDeviceId() : "N/A") : "N/A";
}
publicstaticStringgetSN() {
String deviceSN = "N/A";
try {
Class<?> propClass = Class.forName("android.os.SystemProperties");
Method getProp = propClass.getMethod("get", String.class, String.class);
deviceSN = (String) getProp.invoke(propClass, "gsm.sn1", "N/A");
} catch (Exception ignored) {
}
return deviceSN;
}
publicstaticStringgetPN() {
String devicePN = "N/A";
try {
Class<?> propClass = Class.forName("android.os.SystemProperties");
Method getProp = propClass.getMethod("get", String.class, String.class);
devicePN = (String) getProp.invoke(propClass, "ro.lenovosn2", "N/A");
} catch (Exception ignored) {
}
return devicePN;
}
Lenovo has custom property names, you can use the following adb command to see all available props:
adb shell getprop
Solution 2:
I used this code to get the serial number from the Lenovo tab 7 Essential (2017 model running Android 7.0). I was also using it to get Samsung serial numbers (Galaxy Camera 1/2 running Android 4 and a Tab A running 6, then updated to 7.1.1).
privatestatic String UNKNOWN = "unknown";
static String GetDeviceSerialNumber() {
String serial;
if (Build.MANUFACTURER.toLowerCase().contains("lenovo")) {
serial = GetLenovoManufacturerSerialNumber();
} else {
serial = GetSamsungManufacturerSerialNumber();
}
if (serial == null || serial.equals(UNKNOWN)) {
serial = Build.SERIAL; // this is NOT usually the serial displayed on the device, but it returns something
}
return serial;
}
// http://stackoverflow.com/questions/14161282/serial-number-from-samsung-device-running-androidprivatestatic String GetSamsungManufacturerSerialNumber() {
String serial = GetSystemPropertyString("ril.serialnumber"); // older Samsung devices - works on Galaxy Camera 1if (serial == null || serial.equals(UNKNOWN)) {
serial = GetSystemPropertyString("sys.serialnumber"); // newer Samsung devices
}
return serial;
}
// https://stackoverflow.com/questions/23773975/how-to-get-real-serial-number-of-lenovo-tab-in-androidprivatestatic String GetLenovoManufacturerSerialNumber() {
return GetSystemPropertyString("ro.lenovosn2");
}
privatestatic String GetSystemPropertyString(String prop) {
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class);
return (String)get.invoke(c, prop, UNKNOWN);
} catch (Exception ignored) {
ignored.printStackTrace();
returnnull;
}
}
Hopefully that's helpful to someone.
Solution 3:
HI you can get everything about your device hardware by using the following code.
Build.BRAND //Brand Name
Build.DEVICE //Device Name
Build.MODEL //Model No
Build.SERIAL //Serial No
import this namespace :: import android.os.Build;
Let me know if my answer is right or not.
Post a Comment for "How To Get Real Serial Number Of Lenovo Tab In Android"