# getDefaultAdapter(); Deprecation

**URL:** <https://discourse.processing.org/t/getdefaultadapter-deprecation/35781>\
**Category:** Processing for Android\
**Created:** [March 16, 2022, 1:40pm UTC](https://discourse.processing.org/t/getdefaultadapter-deprecation/35781 "2022-03-16T13:40:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [March 16, 2022, 1:40pm UTC](https://discourse.processing.org/t/getdefaultadapter-deprecation/35781/1 "2022-03-16T13:40:47Z")

</div>

I use

BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();

in my code to be able to connect with Bluetooth, but unfortunately, this code is already a deprecated method. It still works but I don’t know if it would still be reliable in the future.

So due to this, I tried this code in exchange of the deprecated code above. I use

final BluetoothManager mBluetoothManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH\_SERVICE);  
BluetoothAdapter bluetooth = mBluetoothManager.getAdapter();

but unfortunately, this code crashes.

Any solutions/alternatives for the deprecated code? Or is it ok to use the deprecated code in future developments?
