Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { /** * This device's SN * * @return SerialNumber */ public static String getSerialNumber() { String serialNumber = android.os.Build.SERIAL; if ((serialNumber == null || serialNumber.length() == 0 || serialNumber.contains("unknown"))) { String[] keys = new String[] { "ro.boot.serialno", "ro.serialno" }; for (String key : keys) { try { Method systemProperties_get = Class.forName("android.os.SystemProperties").getMethod("get", String.class); serialNumber = (String) systemProperties_get.invoke(null, key); if (serialNumber != null && serialNumber.length() > 0 && !serialNumber.contains("unknown")) break; } catch (Exception e) { e.printStackTrace(); } } } return serialNumber; } }