-3

Suppose I am using some device to run the android program but now I wanted to know the device name which I m using through code.How can I get it.

Dexter
  • 9
  • 1
  • 5
  • 5 seconds of Googling found my this [See here][1] [1]: http://stackoverflow.com/questions/7071281/get-android-device-name – TMH Oct 21 '13 at 10:58
  • sorry 2 say i have usd this but I m not getting the correct result – Dexter Oct 21 '13 at 11:01

2 Answers2

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


  private static 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);
    }
}
Shivang Trivedi
  • 2,182
  • 1
  • 20
  • 26
2

Use this code to get the Device name:-

String deviceName = android.os.Build.MODEL;
System.out.println("Device Name--"+deviceName);
bakriOnFire
  • 2,685
  • 1
  • 15
  • 27