get Device Serial Number - Android Hardware

Android examples for Hardware:Device ID

Description

get Device Serial Number

Demo Code


//package com.java2s;
import java.lang.reflect.Method;

public class Main {
    /**/*w w w  . j av a2 s .co m*/
     * getSerialNumber
     *
     * @return result is same to getSerialNumber1()
     */
    public static String getSerialNumber() {
        String serial = null;
        try {
            Class<?> c = Class.forName("android.os.SystemProperties");
            Method get = c.getMethod("get", String.class);
            serial = (String) get.invoke(c, "ro.serialno");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return serial;
    }
}

Related Tutorials