Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Android Phone Model programmatically , How to get Device name and model programmatically in android?

I would like to know if there is a way for reading the Phone Model programmatically in Android.

I would like to get a string like HTC Dream, Milestone, Sapphire or whatever...

like image 510
Andrea Baccega Avatar asked Jan 03 '10 16:01

Andrea Baccega


People also ask

How do I find my device model ID?

Open Settings. Tap About phone. Tap Status. Tap IMEI information to show the IMEI or MEID.

How do I find my Android device info?

Go into the Settings menu of your device and check for an option that details the Android system info. This can vary depending on your brand of device and whether it's a phone or a tablet. As you can see from this screenshot, all we can really glean from this information screen is the model name and Android version.

How do I find my device name and model?

Check your phone's settingsGo to the Settings or Options menu, scroll to the bottom of the list, and check 'About phone', 'About device' or similar. The device name and model number should be listed.


2 Answers

I use the following code to get the full device name. It gets model and manufacturer strings and concatenates them unless model string already contains manufacturer name (on some phones it does):

public String getDeviceName() {     String manufacturer = Build.MANUFACTURER;     String model = Build.MODEL;     if (model.toLowerCase().startsWith(manufacturer.toLowerCase())) {         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);     } }  

 

Here are a few examples of device names I got from the users:

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

like image 120
Idolon Avatar answered Sep 21 '22 03:09

Idolon


On many popular devices the market name of the device is not available. For example, on the Samsung Galaxy S6 the value of Build.MODEL could be "SM-G920F", "SM-G920I", or "SM-G920W8".

I created a small library that gets the market (consumer friendly) name of a device. It gets the correct name for over 10,000 devices and is constantly updated. If you wish to use my library click the link below:

AndroidDeviceNames Library on Github


If you do not want to use the library above, then this is the best solution for getting a consumer friendly device name:

/** Returns the consumer friendly device name */ public static String getDeviceName() {   String manufacturer = Build.MANUFACTURER;   String model = Build.MODEL;   if (model.startsWith(manufacturer)) {     return capitalize(model);   }   return capitalize(manufacturer) + " " + model; }  private static String capitalize(String str) {   if (TextUtils.isEmpty(str)) {     return str;   }   char[] arr = str.toCharArray();   boolean capitalizeNext = true;    StringBuilder phrase = new StringBuilder();   for (char c : arr) {     if (capitalizeNext && Character.isLetter(c)) {       phrase.append(Character.toUpperCase(c));       capitalizeNext = false;       continue;     } else if (Character.isWhitespace(c)) {       capitalizeNext = true;     }     phrase.append(c);   }    return phrase.toString(); } 

Example from my Verizon HTC One M8:

// using method from above System.out.println(getDeviceName()); // Using https://github.com/jaredrummler/AndroidDeviceNames System.out.println(DeviceName.getDeviceName()); 

Result:

HTC6525LVW

HTC One (M8)

like image 21
Jared Rummler Avatar answered Sep 23 '22 03:09

Jared Rummler