显示Android蓝牙设备名称
如何在android中使用Java显示蓝牙设备名称? 我可以参考的任何代码?
下面的代码将获得蓝牙名称,这里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; }