‘App is scanning too frequently’ with ScanSettings.SCAN_MODE_OPPORTUNISTIC

Android 7 prevents scan start-stops more than 5 times in 30 seconds. The bad side is, it doesn’t return an error, instead just prints a log. The app thinks the scan is started but it’s not actually started back at the ble stack. Also it converts long running scans to opportunistic scan with an intent … Read more

Bluetooth HCI snoop log not generated

UPDATE: The btsnoop hci log seems to be getting phased out of the user-accessible areas on a lot of phones. Assuming you have hci logging enabled, you can get a bugreport adb bugreport anewbugreportfolder Then decompress the folder. If you’re lucky there is an ‘FS’ folder that contains the btsnoop_hci.log log several layers down (not … Read more

Communicating between iOS and Android with Bluetooth LE

I’ve already gone through this for at least one week having this same issue. I’ve already asked a question here and I’ve already answered on my own. The main problem is an Android BUG issue. It’s sending a non permitted command on a fixed L2CAP channnel. But when Android is communicating with normal peripheral BLE … Read more

Android 12 New Bluetooth Permissions

100% working solution : no need any 3rd party plugin manifest code: <!–BLUETOOTH PERMISSION–> <!– Request legacy Bluetooth permissions on older devices. –> <uses-permission android:name=”android.permission.BLUETOOTH” /> <uses-permission android:name=”android.permission.BLUETOOTH_ADMIN” /> <!– Needed only if your app looks for Bluetooth devices. If your app doesn’t use Bluetooth scan results to derive physical location information, you can strongly … Read more

Can an Android device act as an iBeacon?

YES This is possible on Android 5+, and you can find open-source code for transmitting as a beacon in the Android Beacon Library. There is also a full-featured version of a beacon transmitter in the Beacon Scope app in the Google Play Store. Here’s an example of transmitting iBeacon with the Android Beacon Library: Beacon … Read more

How can I programmatically tell if a Bluetooth device is connected?

Add the Bluetooth permission to your AndroidManifest, <uses-permission android:name=”android.permission.BLUETOOTH” /> Then use intent filters to listen to the ACTION_ACL_CONNECTED, ACTION_ACL_DISCONNECT_REQUESTED, and ACTION_ACL_DISCONNECTED broadcasts: public void onCreate() { … IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); this.registerReceiver(mReceiver, filter); } //The BroadcastReceiver that listens for bluetooth broadcasts private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override … Read more

Android 4.3 Bluetooth Low Energy unstable

Important implementation hints (Perhaps some of those hints aren’t necessary anymore due to Android OS updates.) Some devices like Nexus 4 with Android 4.3 take 45+ seconds to connect using an existing gatt instance. Work around: Always close gatt instances on disconnect and create a fresh instance of gatt on each connect. Don’t forget to … Read more