What do I use now that BluetoothAdapter.getDefaultAdapter() is deprecated?

As you can see here, they now recommend this: val bluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager bluetoothManager.getAdapter() The reason seems to be that BluetoothAdapter.getDefaultAdapter() ignores Context, while more complex apps might need to explicitly reference the correct Context. Not a good reason to deprecate it in my opinion, as I can’t think of a realistic/frequent usecase … Read more

Android: BluetoothSocket receives its own output

I scoured over the Bluetooth classes sources. The workaround seems legit from the first glances. Try this first: if (delay == 0) { Log.i(“WRT”, “Written to RaspberryPi”); out.write(“Hello Raspberry. It’s me, AndroidPhone”.getBytes()); out.flush(); // <– You are not flushing delay = 100000000; } And the message sticks in you socket for you to read over … Read more

‘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

tech