2017-01-15 35 views
-5

Androidスタジオは、mBluetoothManagerが不明なクラスですと言っています。誰でも説明できますか?mBluetoothManager =(BluetoothManager)getSystemService(Context.BLUETOOTH_SERVICE); mBtAdapter = mBluetoothManager.getAdapter();

mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 
mBtAdapter = mBluetoothManager.getAdapter(); 
+2

[よく質問するにはどうすればよいですか?](http://stackoverflow.com/help/how-to-ask)、[最小限の完全かつ検証可能なサンプルを作成する方法](http ://stackoverflow.com/help/mcve)。 – giusti

答えて

0

変数を初期化する前に宣言しましたか? (difference in terms explained here)

あなたはしなかった場合は、変数を宣言するために、このような、ここでタイプを追加してみてくださいすることができます

BluetoothManager mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 
BluetoothAdapter mBtAdapter = mBluetoothManager.getAdapter(); 

また、あなたはファイルの先頭に次のようにインポートされた権利のクラスを持っていることを確認してください。

import android.bluetooth.BluetoothAdapter; 
import android.bluetooth.BluetoothManager; 

Androidスタジオでは、プロジェクトビューでファイルを右クリックして[インポートの最適化]を選択すると、インポートするクラスを見つけることができます。これにはキーボードショートカットもありますが、それはおそらくオペレーティングシステム固有のものですので、私はそれを見てみましょう。

関連する問題