显示Android的蓝牙设备名称 [英] Display Android Bluetooth Device Name

查看:772
本文介绍了显示Android的蓝牙设备名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示在Android中,它使用Java的蓝牙设备名称?任何codeS对我来说,是指什么?

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

推荐答案

以下code将得到ü蓝牙的名称,在这里 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆