Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 显示Android蓝牙设备名称_Java_Android_Eclipse_Bluetooth_Device Name - Fatal编程技术网

Java 显示Android蓝牙设备名称

Java 显示Android蓝牙设备名称,java,android,eclipse,bluetooth,device-name,Java,Android,Eclipse,Bluetooth,Device Name,如何在使用Java的android中显示蓝牙设备名称?有我要参考的代码吗?下面的代码将得到你的蓝牙名称,这里的mBluetoothAdapter是BluetoothAdapter类型 public String getLocalBluetoothName(){ if(mBluetoothAdapter == null){ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); } String

如何在使用Java的android中显示蓝牙设备名称?有我要参考的代码吗?

下面的代码将得到你的蓝牙名称,这里的
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;
}

谢谢你,侯赛因!它与我的代码配合得很好。但是,如果我要检索手机地址,也可以采用相同的方式?
import android.provider.Settings.Secure;私有字符串android\u id=Secure.getString(getContext().getContentResolver(),Secure.android)这将有助于获取android的唯一iddevice@TunA:
TelephonyManager tManager=(TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_服务);字符串uid=tManager.getDeviceId()活动类。getDeviceID()将返回设备的MDN或MEID,具体取决于手机使用的无线电设备(GSM或CDMA)。但是,我要检索的是android设备的序列号,而不是连接到PC的蓝牙设备的手机地址。。你有什么办法可以向我解释清楚吗?你需要蓝牙设备的地址吗?