小编use*_*164的帖子

Android搜索蓝牙设备

我正在尝试找到可用的蓝牙设备.

这是我的OnClickListener,当用户尝试搜索可用设备时会调用它.

View.OnClickListener OnSearchDevices = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            //Toast.makeText(context, "Search Devices", Toast.LENGTH_LONG).show();
            Log.d("Discovery", "Started");
            listOfDevices.clear();
            label.setText("Searching Available Devices...");
            label.setEnabled(false);
        }
    };
Run Code Online (Sandbox Code Playgroud)

我还注册了BroadcastReceiver.

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

            // When discovery finds a device
            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                // Get the BluetoothDevice object from the Intent
                BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                Log.d("DeviceList" , device.getName() + "\n" + …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

6
推荐指数
1
解决办法
7575
查看次数

标签 统计

android ×1

bluetooth ×1