3

This is what I tried.

mTextView.setText("MODEL: "+android.os.Build.MODEL
                +"\nDEVICE: "+android.os.Build.DEVICE
                +"\nBRAND: "+android.os.Build.BRAND
                +"\nDISPLAY: "+android.os.Build.DISPLAY
                +"\nBOARD: "+android.os.Build.BOARD
                +"\nHOST: "+android.os.Build.HOST
                +"\nMANUFACTURER: "+android.os.Build.MANUFACTURER
                +"\nPRODUCT: "+android.os.Build.PRODUCT);

Can anyone tell me how to get these outputs:
Samsung Galaxy S
Samsung note 3
Sony Xperia z
Sony Xperai z1
Samsung Grand

for nexus it shows nexus 4 or nexus 7 not the same case with sony or samsung.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rana Ranvijay Singh
  • 6,055
  • 3
  • 38
  • 54
  • 1
    Based on your comments to the answers, it seems that your question is not clear - please rephrase it. `case` - do you mean lowercase/uppercase? What is it that you want? – Melquiades Dec 30 '13 at 12:33
  • I have no issue with lowercase or uppercase.What i want is to get the second part of the device name like "galaxy S, note 3 ,Xperia z or Xperia Z1" , i have the first name ie." Samsung or sony " using android.os.Build.MODEL. Thank you for your reply. – Rana Ranvijay Singh Dec 30 '13 at 12:39

4 Answers4

13

you can use:

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);
  }
} 

see this for Build.MODEL.

more info in Get Android Phone Model Programmatically.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Shayan Pourvatan
  • 11,898
  • 4
  • 42
  • 63
  • 1
    Sorry ,if you can see my code i have tried this. android.os.Build.MODEL and android.os.Build.MANUFACTURER does not give what i am looking for, but thanx for trying. – Rana Ranvijay Singh Dec 30 '13 at 12:21
3

In order to get android device name you have to add only a single line of code:

android.os.Build.MODEL;

Found here:getting-android-device-name

M D
  • 47,665
  • 9
  • 93
  • 114
1

Download csv from here:

https://support.google.com/googleplay/answer/1727131?hl=en

See if your device works with Google Play by checking the list below. When you download the PDF file, devices are ordered alphabetically (A-Z) by manufacturer name.

Then import this file into your database.

Query RetailBranding and Marketing Name by Model = Build.Model.

To have a better performance, put these data in your database server.

Get the RetailBranding and Marketing Name when the app is first launched and save it to the local database.

Kimi Chiu
  • 2,103
  • 3
  • 22
  • 37
0

you can also get it via bluetoothAdapter see this

public String getPhoneName() 
{  
    BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
    String deviceName = myDevice.getName();     
    return deviceName;
}
Community
  • 1
  • 1
Xar-e-ahmer Khan
  • 1,314
  • 15
  • 23
  • Note that not all android devices have bluetooth support, and this will throw a null reference exception in those cases. Otherwise this seems to work pretty well. – lehn0058 May 19 '16 at 17:06
  • @Xar-e-ahmer Khan Thanks for the code snippet, this code works in almost all devices. Any idea on how to get device name when the Bluetooth is OFF. because the above code snippet is having limitation like when user change Device name while Bluetooth is OFF, we get OLD Device name until Bluetooth is turned ON again. – Chethan Shetty Feb 19 '18 at 03:09