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 where the BluetoothAdapter needs to be based on the Context. They should have just left both options (Context based and default) in without deprecation.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)