다른 블루투스 장치를 검색 할 때 발견 된 각 장치에 대해 2 개의 브로드 캐스트가 전송됩니다. 첫 번째는 스캔하는 동안 전송되고 한 번에 검색된 모든 장치에 대해 브로드 캐스트가 전송됩니다. SDK의 BluetoothChat 샘플을 적용하고 있습니다.Android 블루투스 검색
private final BroadcastReceiver foundRec = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(BluetoothDevice.ACTION_FOUND)) {
Log.e(TAG, "--- device found ---");
BluetoothDevice dev = intent
.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (dev.getBondState() == BluetoothDevice.BOND_BONDED) {
availableDevices.add(dev.getName() + " (paired)");
} else {
availableDevices.add(dev.getName());
}
} else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED)){
Log.d(TAG, "DISCOVERY STARTED");
findViewById(R.id.lookup).setVisibility(View.VISIBLE);
}
}
};
감사합니다 :
여기 내 '브로드 캐스트 리시버'입니다!
삼성 기기에서 앱을 테스트하고 있다고 생각하십니까? – waqaslam
어쩌면 나는 그것을 놓쳤다. 그러나 당신의 질문은 무엇인가? –
HTC에서 테스트 중입니다. 질문은 모든 장치가 두 번 발견되는 것을 피하는 방법입니다. –