You can call BluetoothAdapter.getDefaultAdapter()
. BluetoothManager documentation says that
Use getSystemService(java.lang.String) with BLUETOOTH_SERVICE to create an BluetoothManager, then call getAdapter() to obtain the BluetoothAdapter.
Alternatively, you can just call the static helper getDefaultAdapter().
Or you can check build version and initialize mBluetoothAdapter
, like below
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
mBluetoothAdapter = bluetoothManager.getAdapter();
} else {
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}