显示 Android 蓝牙设备名称 [英] Display Android Bluetooth Device Name
本文介绍了显示 Android 蓝牙设备名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在使用 Java 的 android 中显示蓝牙设备名称?有什么代码可以参考吗?
How to display a bluetooth device name in android which uses Java? Any codes for me to refer to?
推荐答案
下面的代码会得到你的蓝牙名称,这里mBluetoothAdapter
是BluetoothAdapter
类型.>
The below code will get u the bluetooth name, here mBluetoothAdapter
is of type BluetoothAdapter
.
public String getLocalBluetoothName(){
if(mBluetoothAdapter == null){
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}
String name = mBluetoothAdapter.getName();
if(name == null){
System.out.println("Name is null!");
name = mBluetoothAdapter.getAddress();
}
return name;
}
这篇关于显示 Android 蓝牙设备名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文