Android:获取本机已配对蓝牙列表

1. AndroidManifest.xml 配置文件中加入蓝牙许可权限:  <uses-permission android:name="android.permission.BLUETOOTH"/>

           BluetoothAdapter bluetoothAdapter =BluetoothAdapter.getDefaultAdapter();
if(bluetoothAdapter == null) { System.out.println("本机未发现蓝牙设备。"); }else { if(!bluetoothAdapter.isEnabled())//判断蓝牙设备是否已开起 { //开起蓝牙设备 Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivity(intent); } Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices(); for(Iterator<BluetoothDevice> iterator = devices.iterator();iterator.hasNext();) { BluetoothDevice device = iterator.next(); System.out.println(device.getAddress()); } }
原文地址:https://www.cnblogs.com/you000/p/2809093.html