1.在AndroidManifest.xml中配置
<uses-permission android:name="android.permission.BLUETOOTH"/>2. //1.获得BluetoothAdapter对象 BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter(); //2.判断当前设备中是否拥有蓝牙设备 if(adapter != null){ System.out.println("本机拥有蓝牙设备"); } //3.判断当前设备中的蓝牙设备是否已经打开 if(adapter.isEnabled()){ Intent intent=new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivity(intent); } //4.得到所有已经配对的蓝牙设备对象 Set<BluetoothDevice> devices=adapter.getBondedDevices(); if(devices.size() >0){ for(Iterator iterator= devices.iterator(); iterator.hasNext();){ BluetoothDevice bluetoothDevice=(BluetoothDevice) iterator.next(); System.out.println(bluetoothDevice.getAddress()); } }else{ System.out.println("没有蓝牙设备!"); } }