Android:以编程方式获取设备名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20839301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:34:44  来源:igfitidea点击:

Android: Get the device name programmatically

android

提问by Rana Ranvijay Singh

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 4or nexus 7not the same case with sony or samsung.

谁能告诉我如何获得这些输出:
Samsung Galaxy S
Samsung note 3
Sony Xperia z
Sony Xperai z1
Samsung Grand

for nexus 它显示nexus 4nexus 7与索尼或三星的情况不同。

回答by Shayan Pourvatan

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.

看到这个Build.MODEL。

more info in Get Android Phone Model Programmatically.

编程方式获取 Android 手机模型中的更多信息。

回答by M D

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

为了获得 android 设备名称,您只需添加一行代码:

android.os.Build.MODEL;

Found here:getting-android-device-name

在这里找到:getting-android-device-name

回答by Kimi Chiu

Download csv from here:

从这里下载 csv:

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

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.

查看下面的列表,看看您的设备是否适用于 Google Play。下载 PDF 文件时,设备按制造商名称的字母顺序 (AZ) 排序。

Then import this file into your database.

然后将此文件导入您的数据库。

Query RetailBrandingand Marketing Nameby Model = Build.Model.

查询RetailBrandingMarketing Name通过Model = Build.Model

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

为了获得更好的性能,请将这些数据放在您的数据库服务器中。

Get the RetailBrandingand Marketing Namewhen the app is first launched and save it to the local database.

获取RetailBrandingMarketing Name当应用程序首次启动,并将其保存到本地数据库。

回答by Xar-e-ahmer Khan

you can also get it via bluetoothAdapter see this

你也可以通过 bluetoothAdapter 看到这个

public String getPhoneName() 
{  
    BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
    String deviceName = myDevice.getName();     
    return deviceName;
}