블루투스 켜짐/꺼짐 : BluetoothAdapter.ACTION_STATE_CHANGED
기기 연결/해제 : BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED
켜짐/꺼짐
int bluetoothState = $intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
if (bluetoothState == BluetoothAdapter.STATE_OFF)
{
}
else if (bluetoothState == BluetoothAdapter.STATE_ON)
{
}
연결/해제
else if (BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(action))
{
BluetoothDevice device = $intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device == null)
return;
int bluetoothState = $intent.getIntExtra(BluetoothA2dp.EXTRA_STATE, BluetoothA2dp.STATE_DISCONNECTED);
if (bluetoothState == BluetoothA2dp.STATE_CONNECTED)
{
}
else if (bluetoothState == BluetoothA2dp.STATE_DISCONNECTED)
{
}
}