//mBluetoothAdapter.enable(); } 4.获取已经配对的设备 //获取已经配对的设备 SetpairedDevices=mBluetoothAdapter.getBondedDevices(); //判断是否有配对过的设备 if(pairedDevices.size()>0){ for(BluetoothDevicedevice:pairedDevices){ //遍历到列表中 tvDevices.append(device.getName()+":"+device.getAddr...
for (BluetoothDevice device : pairedDevices) { // 遍历到列表中 tvDevices.append(device.getName() + ":" + device.getAddress()); Log.i("已配对设备", tvDevices.getText().toString()); } } /** * 异步搜索蓝牙设备——广播接收 */ // 找到设备的广播 IntentFilter filter = new IntentFilter...
void initDevicePreference(BluetoothDevicePreference preference) { CachedBluetoothDevice cachedDevice = preference.getCachedDevice(); if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) { // Only paired device have an associated advanced settings screen //假设设备已经配对,则加入监听事件 prefe...
void initDevicePreference(BluetoothDevicePreference preference) { CachedBluetoothDevice cachedDevice = preference.getCachedDevice(); if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) { // Only paired device have an associated advanced settings screen //假设设备已经配对,则加入监听事件 prefe...
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(intent, 1); // 不做提示,强行打开 // mBluetoothAdapter.enable(); } 4.获取已经配对的设备// 获取已经配对的设备 SetpairedDevices = mBluetoothAdapter.getBondedDevices(); ...
(BluetoothDevicePreference preference){CachedBluetoothDevice cachedDevice=preference.getCachedDevice();if(cachedDevice.getBondState()==BluetoothDevice.BOND_BONDED){// Only paired device have an associated advanced settings screen//如果设备已经配对,则添加监听事件preference.setOnSettingsClickListener(mDevice...
ERROR); if (state == BluetoothDevice.BOND_BONDED && prevState == BluetoothDevice.BOND_BONDING) { showToast("Paired"); } else if (state == BluetoothDevice.BOND_NONE && prevState == BluetoothDevice.BOND_BONDED){ showToast("Unpaired"); } mAdapter.notifyDataSetChanged(); } } ...
android.permission.BLUETOOTH允许程序连接到已配对的蓝牙设备(Allows applications to connect to paired bluetooth devices) android.permission.BLUETOOTH_ADMIN允许程序发现和配对蓝牙设备(Allows applications to discover and pair bluetooth devices) android.permission.BRICK请求能够禁用设备(非常危险)(Required to be able...
android.permission.BLUETOOTH_ADMIN允许程序发现和配对蓝牙设备(Allows applications to discover and pair bluetooth devices) android.permission.BRICK请求能够禁用设备(非常危险)(Required to be able to disable the device (very dangerous!).) android.permission.BROADCAST_PACKAGE_REMOVED允许程序广播一个提示消息在一...
syncBluetoothState(); } } 1.1.1 bluetoothAdapter的enable函数分析 其实我们会发现,这个函数最终还是调用的bluetoothService中的enable函数,所以,这里就不详细说了,直接去看bluetoothService中的enable /** Bring up BT and persist BT on in settings */ ...