0

There are many apps which require location permission to operate. For example, BUMBLE. While using the app, if I disable location from the notification bar, it immediately knows, and degrades the functionality, while preserving the state of the app. When I turn it back on, it resumes full functionality. How to implement the same thing in my Android app? Bluetooth being enabled is crucial to the functioning of my app.

EDIT: I'm mainly interested in implementing a similar system for Bluetooth. My app involves many activities like scanning for ble devices, maintaining ble connections and communication, etc, which makes the app crash when the user turns off bluetooth from the notification bar.

1 Answers1

0

You can use the FusedLocationProviderClient to request location updates. One of the callback functions tells you the location availability. See Request Location Updates.

Note that you'll need to call the requestLocationUpdates that takes a LocationCallback to override the onLocationAvailability function.

For Bluetooth, you need to listen for a system broadcast. See Detecting state changes made to the BluetoothAdapter?

I'm not positive this still works; it's a rather old answer (I remember using that approach a long while back) but it might not work with more recent bluetooth

Scott Stanchfield
  • 29,742
  • 9
  • 47
  • 65