안녕하세요. 블루투스 검색 후 디바이스를 가져오지 못하여 질문 드립니다.
기본적으로 퍼미션은 다 넣었군요.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
블루투스 검색 할 상대 기기의 상태도 정상입니다.
(설정 메뉴의 블루투스 검색 기능 활용 시 정상 검색됨을 확인 완료)
하기 코드의 bluetoothAdapter.startDiscovery(); 도 정상 작동하여 검색하는 것도 확인 하였습니다.
해당 코드의 리시버도 동작하는 것도 확인하였습니다.
onDestroy 시 unregisterReceiver 도 물론 등록 완료.
하지만 if (BluetoothDevice.ACTION_FOUND.equals(action)) 이 코드 부터 동작을 안합니다.
뭐가 문제 일까요... 도화주세요. 고수님들.
========================== CODE ==========================
블루투스 어뎁터 startDiscovery 관련 코드
bluetoothText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!bluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
} else if (bluetoothAdapter.isEnabled()){
if(bluetoothAdapter.isDiscovering()){
bluetoothAdapter.cancelDiscovery();
}
findBluetoothDevice();
bluetoothAdapter.startDiscovery();
makePairedDeviceDialog();
}
}
}
});
============================================================
블루투스 리시버 코드
void findBluetoothDevice() {
mBluetoothSearchReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice devices = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Log.v("configuration", "디바이스 이름 : " + devices.getName());
Log.v("configuration", "디바이스 이름 : " + devices.getAddress());
}
}
};
mSearchFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
mSearchFilter.addAction(BluetoothDevice.ACTION_FOUND);
registerReceiver(mBluetoothSearchReceiver, mSearchFilter);
}
============================================================