Stack Overflow archive
2 score

Get codename of android device

score
2
question views
4.1K
license
CC BY-SA 3.0

You should get the value of "ro.build.product". This is how you should get the codename of a device:

java
public static String getCodename() {
    String value = Build.DEVICE;
    try {
        final Class<?> sp = Class.forName("android.os.SystemProperties");
        final Method get = sp.getMethod("get", String.class);
        value = (String) get.invoke(null, "ro.build.product");
    } catch (Exception ignored) {
    }
    return value;
}

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.