簡體   English   中英

如何通過Android應用程序過濾藍牙標簽

[英]How to filter bluetooth tags through android apps

與應用配對時如何過濾藍牙標簽。 例如,“瓷磚”不與除其授權標簽以外的其他標簽連接。 我的問題是,他們如何通過應用識別他們的授權標簽?

一種簡單的解決方案是連接到不受信任的設備,發送預期具有特定結果的信號,如果接收良好,則“信任”該設備。

然后,在下次加載時,檢查配對的MAC地址。

類似於:

private BluetoothDevice mDevice = null;
if (mDevice == null) {
        BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mBluetoothAdapter != null) {
            if (mBluetoothAdapter.isEnabled()) {
                Set<BluetoothDevice> bluetoothDevices = mBluetoothAdapter
                        .getBondedDevices();
                if (bluetoothDevices != null && bluetoothDevices.size() > 0) {
                    String bondedID = SharedPreferences.getInstance(
                            getApplicationContext()
                    ).getPairedAddress();
                    if (bondedID != null) {
                        for (final BluetoothDevice device : bluetoothDevices) {
                            if (device != null
                                    && device.getAddress().equals(bondedID)) {
                                mDevice = device;
                                break;
                            }
                        }
                    }
                } else {
                    Logger.v(TAG, "There are no Bluetooth Paired devices");
                }
            }
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM