BluetoothProfile.ServiceListener
블루투스 상태를 알수있는 리스너가 있나요? 블루투스가 연결이 되었다던지 연결이 끊겼다던지 알수있는 리스너같은게 있을 것 같은데 키워드좀 알려주십시오. ㅠㅠ
serviceListener로 구현하니
불러줘야지만 상태확인이 가능하더라고요..
BT가 끊기거나 BT가 연결이되면 바로 알수있는 방법 없나요 ?
블루투스 켜짐/꺼짐 : BluetoothAdapter.ACTION_STATE_CHANGED
기기 연결/해제 : BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED
켜짐/꺼짐
int
bluetoothState = $intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
if
(bluetoothState == BluetoothAdapter.STATE_OFF)
{
}
else
(bluetoothState == BluetoothAdapter.STATE_ON)
연결/해제
(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(action))
BluetoothDevice device = $intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
(device ==
null
)
return
;
bluetoothState = $intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, BluetoothA2dp.STATE_DISCONNECTED);
(bluetoothState == BluetoothA2dp.STATE_CONNECTED)
(bluetoothState == BluetoothA2dp.STATE_DISCONNECTED)