You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (mBluetoothLEScanner == null) {
// create bluetoothLE scanner if it is null
mBluetoothLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
}
// start scan bluetooth
mBluetoothLEScanner.startScan(
null,
buildScanSettings(),
mProxyScanCallback);
Hi, Since Marshmallow you have to request Location permission (fine or coarse) in order to scan for Bluetooth LE devices. This is a Runtime permission, so you have to ask user to allow.
Check out this link: https://developer.android.com/training/permissions/requesting
Bluetooth LE devices, like beacons, can reveal phone's location. That's why user needs to allow it. Also, on most devices the Location must be enabled in the phone.
Thanks you for response, philips77. But in AndroidManifest file, i requested Location permission as following:
uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
uses-permission android:name="android.permission.BLUETOOTH" />
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
But App only scan device android < 6.0.1, cannot scan device Sony Xperia Z3 android 6.0.1.
Hi all,
this code for scanning BLE device:
if (mBluetoothLEScanner == null) {
// create bluetoothLE scanner if it is null
mBluetoothLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
}
// start scan bluetooth
mBluetoothLEScanner.startScan(
null,
buildScanSettings(),
mProxyScanCallback);
private ScanSettings buildScanSettings() {
ScanSettings.Builder builder = new ScanSettings.Builder();
builder.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER);
builder.setReportDelay(0);
return builder.build();
}
Setting:
I cannot found device android >= 6.0.1, but can scan other device
There are any problem?Thank you.
The text was updated successfully, but these errors were encountered: