Bluetooth - Turn off discoverable

lymey

Active Member
Licensed User
Longtime User
I am writing an app that requires the option to keep Bluetooth on, allows the device to be discoverable for a period of time, and when an activity has been completed by the user manually turn off discoverable but keep Bluetooth active.
Since the user activity may take a variable amount of time simply setting the number of seconds discoverable isn't really feasible.

I can make it happen by using this:
Dim TimeDiscoverable As Int
TimeDiscoverable = 1
ToastMessageShow("Time discoverable: " & TimeDiscoverable, True)
Dim i As Intent
i.Initialize("android.bluetooth.adapter.action.REQUEST_DISCOVERABLE", "")
i.PutExtra("android.bluetooth.adapter.extra.DISCOVERABLE_DURATION", TimeDiscoverable)
StartActivity(i)
SerialAdapter.Listen

which is a bit clunky...is there a way to do this?
:sign0104:
 

lymey

Active Member
Licensed User
Longtime User
Sorry, perhaps I wasnt being clear...I want to be able to turn off being discoverable manually, but keep bluetooth on.

I can manually change the time discoverable to 300 seconds.

The user activity may not last for 300 seconds, it could be say 20 or 150 seconds, hence the need to turn off being discoverable manually.

I can manually change the time discoverable to say 1 second as in the code sample to keep bluetooth alive and have discoverable timeout quickly.

Does that make sense...perhaps android only allows you to turn on being discoverable manually and not to turn it off without turning off bluetooth?
 
Upvote 0
Top