2016-11-20 71 views
0

我目前正在研究一個應用程序,在該應用程序中,我需要掃描通過Bluetooth classic安裝了我的應用程序的移動設備。我知道有一種藍牙LE的掃描方法,它接受APPLICATION_UUID。 如果有人知道BT Classic的方法,請提前致謝,分享, 。Bluetooth Classic:僅掃描特定設備

回答

0

似乎還有用於BT經典沒有這樣的方法,但它的Device Class您可以過濾「掃描」設備:

BroadcastReceiver mReceiver = new BroadcastReceiver(){ 
     @Override 
     public void onReceive(Context context, Intent intent) { 
      String action = intent.getAction(); 

      if(action.equals(BluetoothDevice.ACTION_FOUND)){ 
       BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 

       if(btDevice .getBluetoothClass().getDeviceClass() == BluetoothClass.Device.<your_class>) { 
        // do your magic with filtered device 
       } 
      } 

您還可以檢查幾個設備類:

int deviceClass = btDevice .getBluetoothClass().getDeviceClass() 

if (deviceClass == Device.AUDIO_VIDEO_WEARABLE_HEADSET 
         || deviceClass == Device.AUDIO_VIDEO_CAR_AUDIO 
         || deviceClass == Device.AUDIO_VIDEO_HANDSFREE 
         and so on.