Android studio keeps saying mBluetoothManager
is an unknown class. Can anyone explain?
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBtAdapter = mBluetoothManager.getAdapter();
Android studio keeps saying mBluetoothManager
is an unknown class. Can anyone explain?
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBtAdapter = mBluetoothManager.getAdapter();
Did you declare the variables before initializing them? (difference in terms explained here)
You can try adding the types here like this to declare the variables if you did not:
BluetoothManager mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter mBtAdapter = mBluetoothManager.getAdapter();
Also, make sure you have the right classes imported like this at the top of the file:
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
Android Studio can help you find which classes to import by right clicking on the file in the project view and selecting 'Optimize imports'. There is also a keyboard shortcut for this but it is probably Operating System-specific so I'll let you look it up.