2012-09-19 114 views
0

我有一部android手机和条码扫描器。要使用扫描仪,我将它与手机配对,但在我的应用程序中,我希望有一点断开扫描仪,所以要做到这一点,我认为一个不成功就足够了。我尝试从here 接受的答案,但它不起作用。也许BluetoothDevice对象不正确?Android如何取消配对蓝牙扫描器

String mac = BluetoothAdapter.getDefaultAdapter().getAddress(); 
BluetoothDevice bluetoothDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(mac); 

其实我一直不明白该怎么把地址getRemoteDevice()方法,所以我把手机蓝牙MAC地址。我应该在那里放置其他地址吗?我将不胜感激任何答案。

预先感谢您

+0

您应该使用远程设备的地址,而不是您自己的地址。 – TJD

回答

0

,一旦你选择扫描仪,你会被它存储在

BluetoothDevice device; 

然后只用device.getAddress获取地址();

,如果你是调用不同的活动您取消配对,然后你只需要把这个地址捆绑,然后通过获取远程设备:

BluetoothDevice bluetoothDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address); 

我希望这会工作。