-5

Android studio keeps saying mBluetoothManager is an unknown class. Can anyone explain?

mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBtAdapter = mBluetoothManager.getAdapter();
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
  • 3
    Please read: [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and also [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – giusti Jan 15 '17 at 19:48

1 Answers1

0

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.

Community
  • 1
  • 1
Pat Myron
  • 4,437
  • 2
  • 20
  • 39