Display Android Bluetooth Device Name

TunA picture TunA · Jul 12, 2011 · Viewed 24.6k times · Source

How to display a bluetooth device name in android which uses Java? Any codes for me to refer to?

Answer

Hussain picture Hussain · Jul 12, 2011

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