低功耗蓝牙扫描失败 [英] Scanning of Bluetooth Low Energy Fails

查看:55
本文介绍了低功耗蓝牙扫描失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个将使用低功耗蓝牙的应用程序.

I am currently developing an application that will use Bluetooth Low Energy.

我正在使用以下链接,

http://developer.android.com/samples/BluetoothLeGatt/src/com.example.android.bluetoothlegatt/DeviceScanActivity.html

我无法扫描周围的 BLE 设备.

I am not able to scan the surrounding BLE devices.

要扫描设备,

mBluetoothAdapter.startLeScan(mLeScanCallback); 

private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() 
    {

        @Override
        public void onLeScan(final BluetoothDevice device, int rssi,byte[] scanRecord) 
        {

            runOnUiThread(new Runnable() {
                @Override
                public void run() 
                {

                    mLeDeviceListAdapter.addDevice(device);

                    mLeDeviceListAdapter.notifyDataSetChanged();

                }
            });
        }
    };

推荐答案

我遇到了同样的问题,请将这些权限添加到您的清单中

I had the same problem please add these permissions to your manifest

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

这篇关于低功耗蓝牙扫描失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆