如何获取Android设备名称?我正在使用HTC欲望。当我通过HTC Sync连接它时,软件显示“HTC Smith”的名称。我想通过代码获取这个名称。
这在Android中是如何实现的呢?
如何获取Android设备名称?我正在使用HTC欲望。当我通过HTC Sync连接它时,软件显示“HTC Smith”的名称。我想通过代码获取这个名称。
这在Android中是如何实现的呢?
当前回答
通用的方法,让用户定义的DeviceName工作几乎所有设备,不需要任何权限
String userDeviceName = Settings.Global.getString(getContentResolver(), Settings.Global.DEVICE_NAME);
if(userDeviceName == null)
userDeviceName = Settings.Secure.getString(getContentResolver(), "bluetooth_name");
其他回答
以下对我有用。
String deviceName = Settings.Global.getString(.getContentResolver(), Settings.Global.DEVICE_NAME);
我不认为这是重复的答案。上面的ppl正在谈论设置安全,为我设置安全是给空,如果我使用设置全局它工作。不管怎样,谢谢你。
简单地使用
BluetoothAdapter.getDefaultAdapter () . getname ()
试一试。您可以通过蓝牙获取设备名称。
希望对你有所帮助
public String getPhoneName() {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
return deviceName;
}
首先,
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 doc:
制造商: 字符串制造商 产品/硬件的制造商。 模型: 字符串模型 最终产品的最终用户可见的名称。 设备: 字符串的设备 工业设计的名称。
举个例子:
String deviceName = android.os.Build.MANUFACTURER + " " + android.os.Build.MODEL;
//to add to textview
TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(deviceName);
此外,在Build类中有很多你可以使用的属性,比如:
android操作系统。棋盘构建。 android操作系统。布兰德构建。 android操作系统。BOOTLOADER构建。 显示屏构建android操作系统。。 android操作系统。CPU_ABI构建。 android os。构建的广告。 os硬件构建android。 android操作系统。ID构建。
还有其他方法可以在不使用Build类的情况下获取设备名称(通过蓝牙)。