Home > Software design >  Is it possible to get notified when the ACTION_REQUEST_DISCOVERABLE timeout expires?
Is it possible to get notified when the ACTION_REQUEST_DISCOVERABLE timeout expires?

Time:08-27

In my code, I make my device discoverable by using the REQUEST_DISCOVERABLE intent. This makes the device discoverable until a certain timeout expires. That timeout can be configured with the EXTRA_DISCOVERABLE_DURATION int field.

However, I haven't found a way to get notified when the timeout expires. I could just start my own timer, but this seems fragile; what if the discoverable state is ended by some other means, for example by user intervention in the Bluetooth settings? It would therefore be useful to somehow be notified by Android that the device is no longer discoverable. Any suggestions? Are there callbacks for this?

CodePudding user response:

Take a look at the description of ACTION_REQUEST_DISCOVERABLE. It states:

Applications can also listen for ACTION_SCAN_MODE_CHANGED for global notification whenever the scan mode changes. For example, an application can be notified when the device has ended discoverability.

  • Related