연결된 블루투스 헤드셋 목록 가져오는 걸 계속 찾았지만, 결국은 찾지 못했다. 그러다가 최근에 블루투스 헤드셋 제작업체에서 준 예제 소스에서 이 부분을 찾아냈다 ㅎㅎ
public void checkConnected(Context $context) { // true == headset connected && connected headset is support hands free int state = BluetoothAdapter.getDefaultAdapter().getProfileConnectionState(BluetoothProfile.HEADSET); if (state != BluetoothProfile.STATE_CONNECTED) return; try { BluetoothAdapter.getDefaultAdapter().getProfileProxy($context, serviceListener, BluetoothProfile.HEADSET); } catch (Exception e) { e.printStackTrace(); } } private ServiceListener serviceListener = new ServiceListener() { @Override public void onServiceDisconnected(int profile) { } @Override public void onServiceConnected(int profile, BluetoothProfile proxy) { for (BluetoothDevice device : proxy.getConnectedDevices()) { Log.i("onServiceConnected", "|" + device.getName() + " | " + device.getAddress() + " | " + proxy.getConnectionState(device) + "(connected = " + BluetoothProfile.STATE_CONNECTED + ")"); } BluetoothAdapter.getDefaultAdapter().closeProfileProxy(profile, proxy); } };
아쉽지만 핸즈프리를 지원하는 헤드셋이 연결됐을 때만 사용가능하다. 그래서 내 젠하이저 PX210BT는 사용이 불가하다.
그래서 핸즈프리가 지원되지 않는 헤드폰이 연결됐는지 확인하려면 BluetoothProfile.A2DP 로 확인해야한다.
BluetoothProfile.A2DP : headphone BluetoothProfile.HEADSET : headset(support hands free)