今天就跟大家聊聊有關(guān)Android應(yīng)用中藍(lán)牙自動匹配PIN碼時怎么跳過用戶交互,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

1.斷開已配對設(shè)備
最后在項目中發(fā)現(xiàn)沒有用。這里就先記錄一下。
//得到配對的設(shè)備列表,清除已配對的設(shè)備
public void removePairDevice() {
if (mBluetoothAdapter != null) {
//mBluetoothAdapter初始化方式 mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
//這個就是獲取已配對藍(lán)牙列表的方法
Set<BluetoothDevice> bondedDevices = mBluetoothAdapter.getBondedDevices();
for (BluetoothDevice device : bondedDevices) {
//這里可以通過device.getName() device.getAddress()來判斷是否是自己需要斷開的設(shè)備
unpairDevice(device);
}
}
}
//反射來調(diào)用BluetoothDevice.removeBond取消設(shè)備的配對
private void unpairDevice(BluetoothDevice device) {
try {
Method m = device.getClass().getMethod("removeBond", (Class[]) null);
m.invoke(device, (Object[]) null);
} catch (Exception e) {
Log.e("mate", e.getMessage());
}
}
文章標(biāo)題:Android應(yīng)用中藍(lán)牙自動匹配PIN碼時怎么跳過用戶交互-創(chuàng)新互聯(lián)
新聞來源:http://chinadenli.net/article30/hhhso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、靜態(tài)網(wǎng)站、電子商務(wù)、網(wǎng)站策劃、網(wǎng)站內(nèi)鏈、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容