如何获取Android设备名称?我正在使用HTC欲望。当我通过HTC Sync连接它时,软件显示“HTC Smith”的名称。我想通过代码获取这个名称。

这在Android中是如何实现的呢?


当前回答

试一试。您可以通过蓝牙获取设备名称。

希望对你有所帮助

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

其他回答

简单地使用

BluetoothAdapter.getDefaultAdapter () . getname ()

首先,

Adb shell getprop >prop_list.txt

第二,

在prop_list.txt中找到您的设备名称以获得道具名称, 例如,我的设备名称是ro.oppo.market.name

最后,

Adb shell getprop ro.oppo.market.name

D:\winusr\adbl

λ adb shell getprop ro.oppo.market.name

成本R17

D:\winusr\adbl

λ

你可以在这里看到答案获得Android手机模型编程

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

以下对我有用。

String deviceName = Settings.Global.getString(.getContentResolver(), Settings.Global.DEVICE_NAME);

我不认为这是重复的答案。上面的ppl正在谈论设置安全,为我设置安全是给空,如果我使用设置全局它工作。不管怎样,谢谢你。

试一试。您可以通过蓝牙获取设备名称。

希望对你有所帮助

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