Can I know the Android device model by code?

Asked 2 years ago, Updated 2 years ago, 143 views

Is there a way to know what Android model is through code in the app?

android android-hardware

2022-09-22 22:17

1 Answers

public String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return capitalize(model);
    } } else {
        return capitalize(manufacturer) + " " + model;
    }
}


private String capitalize(String s) {
    if (s == null || s.length() == 0) {
        return "";
    }
    char first = s.charAt(0);
    if (Character.isUpperCase(first)) {
        return s;
    } } else {
        return Character.toUpperCase(first) + s.substring(1);
    }
} 

If you do this,

Samsung GT-S5830L
Motorola MB860
Sony Ericsson LT18i
LGE LG-P500
HTC Desire V
HTC Wildfire S A510e

You can get these results depending on the model.


2022-09-22 22:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.