Отображение имени устройства Bluetooth для Android
Как отобразить имя устройства Bluetooth в Android, который использует Java? Какие-либо коды для меня, чтобы ссылаться?
1 ответ
Решение
Приведенный ниже код получит имя Bluetooth, здесь mBluetoothAdapter
имеет тип 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;
}