2017-01-15 5 views
-5

안드로이드 스튜디오가 말하기를 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 Studio는 프로젝트보기에서 파일을 마우스 오른쪽 버튼으로 클릭하고 '가져 오기 최적화'를 선택하여 가져올 클래스를 찾을 수 있도록 도와줍니다. 이것에 대한 키보드 단축키도 있지만 운영 체제에 따라 다르므로 직접 살펴 보도록하겠습니다.