2016-11-20 70 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.