阅读背景:

关于Android8.0以下手机获取蓝牙Mac地址的问题和扫描周围的手机蓝牙问题下篇

来源:互联网 

接上篇,接下来我们就来看一下如何扫描到周围的手机蓝牙,重要是经典蓝牙

    // 广播吸收发明蓝牙装备
    private BroadcastReceiver mReceiver = new BroadcastReceiver() {

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

            if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
                Log.i("Lyb", "开端扫描...");

            }

            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                if (device != null) {
       
                    if (device.getType() != BluetoothDevice.DEVICE_TYPE_LE)
                        Log.i("Lyb", "discovery==" + "装备名:" + device.getName() + "\n装备地址:" + device.getAddress());
              
                }
            }

            if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
                Log.i("Lyb", "扫描停止.");
                //
               
            }

        }
    };    // 广播吸收发明



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: