Display Android Bluetooth Device Name

怎甘沉沦 提交于 2019-12-01 04:03:04

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/6662216/display-android-bluetooth-device-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!