/// <summary> /// Clunky implementation of getting connection state for the different profiles. /// Sufficient for our purposes though. Could expand it to include what we're connected /// to as well. /// </summary> /// <returns>The bluetooth connection state.</returns> private ProfileState GetBluetoothConnectionState() { var profileTypes = new ProfileType[] { ProfileType.A2dp, ProfileType.Gatt, ProfileType.GattServer, ProfileType.Headset, ProfileType.Health }; bool connected = profileTypes.Any(pt => BluetoothAdapter.DefaultAdapter.GetProfileConnectionState(pt) == ProfileState.Connected); return(connected ? ProfileState.Connected : ProfileState.Disconnected); }