Android 如何仅扫描附近的可扩展设备
我正在尝试扫描附近的BLE设备,我的设备和我附近的BLE设备都在其中,还有诺基亚525和MOTO G。但它甚至不会扫描单个设备,即使所有这些设备都兼容BLE。我使用以下链接作为我的参考来扫描我的BLE设备:- 清单Android 如何仅扫描附近的可扩展设备,android,bluetooth,bluetooth-lowenergy,android-bluetooth,Android,Bluetooth,Bluetooth Lowenergy,Android Bluetooth,我正在尝试扫描附近的BLE设备,我的设备和我附近的BLE设备都在其中,还有诺基亚525和MOTO G。但它甚至不会扫描单个设备,即使所有这些设备都兼容BLE。我使用以下链接作为我的参考来扫描我的BLE设备:- 清单 <?xml version="1.0" encoding="UTF-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.exampl
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.bluetoothlegatt"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="18"
android:targetSdkVersion="18"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@android:style/Theme.Holo.Light">
<activity android:name=".DeviceScanActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".DeviceControlActivity"/>
<service android:name=".BluetoothLeService" android:enabled="true"/>
</application>
</manifest>
这些设备都不是可升级的外围设备,这正是您扫描的目的。CSR devkit是具有音频配置文件的BT3,而不是可扩展设备。另外两个设备可以是可编程主机,但不是外围设备。我认为Bluez不允许你将Android设备置于BLE外设模式。谢谢你的回答,这真的帮助了我,并为我指明了正确的道路。但我使用的devKit适用于两端,音频配置文件和BLE设备。如果是,那就太好了——不过您需要将其配置为BLE外围设备。我在北欧芯片方面取得了巨大成功。
private void scanLeDevice(final boolean enable)
{
if (enable)
{
// Stops scanning after a pre-defined scan period.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
invalidateOptionsMenu();
}
}, SCAN_PERIOD);
mScanning = true;
mBluetoothAdapter.startLeScan(mLeScanCallback);
} else {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
invalidateOptionsMenu();
}