Is it possible to turn off bluetooth discoverability programmatically on Android?

Of course, given that the user would permit such change. Suppose I set the EXTRA_DISCOVERABLE_DURATION to be 300 second. Is there any way to halt it at the 100th second?

Upvotes: 2

Views: 1784

Answers (1)

Martin Cazares
Martin Cazares

Reputation: 13705

Usually what you have to do is send another Discoverable intent with time 1

Intent discoverable = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverable.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 1);
startActivity(discoverable);

This is more like a hack, but it does the trick, take on count that these actions must be explicitly performed by the user.

Also for a good understanding about how to use the Bluetooth sockets protocol in Android this tutorial explains in detail alot of those things...

Hope it Helps.

Regards!

Upvotes: 2

Related Questions