https://kotlinlang.org logo
Title
f

Francis Mariano

02/23/2023, 2:55 PM
I would like to discuss one thing related to
Flow<Bluetooth.Availability>
. I have the following use case: all permissions is granted, bluetooth adapter is enabled but location service is disabled. The flow emits LocationServicesDisabled which is correct, but after I enable the LocationService, the flow could emit a new state, like Available or Unavailable(reason = Off) What do you think about that???
Sorry, I saw comment in thread https://github.com/JuulLabs/kable/pull/335#issue-1257820206 "Unfortunately, could not find a way to monitor changes to location services status, so only the initial emission of status is provided."
t

travis

02/23/2023, 3:18 PM
Ya, an unfortunate limitation on Android. If you discover a way to monitor for changes (without continually checking on an interval), then let me know.
f

Francis Mariano

02/23/2023, 4:01 PM
@travis Look that
private val locationServiceEnabledFlow: Flow<Boolean> =
    broadcastReceiverFlow(IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION))
        .map { isLocationEnabled }
So we can combine both flows in one
locationServiceEnabledFlow
returns if the location is enabled or disabled
t

travis

02/23/2023, 4:16 PM
Nice. I'll look into it. Thanks!!