How to Set Bluetooth device Discovery Timeout to 1 hour(3600) seconds and Never Time out in android

4.3k Views Asked by At

I am working on Bluetooth App where I want to add the functionality of Manually configuring the Discoverable Timeout Period.When i set DISOVERABLE_DURATION to 120 or 300 it works fine.However it does not provide any response in onActivityResult() when i set it to 3600 seconds.

Similarly I have set DISOVERABLE_DURATION to 0 for Never Time out which not working too.

I have Searched a lot and found that similar Bugs were reported but i could not be able to Find an appropriate Solution.

I am firing the following Intent

Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,DISOVERABLE_DURATION);
startActivityForResult(discoverableIntent,REQUEST_DISCOVERABLE_BT);

Please provide me an appropriate Solution../

1

There are 1 best solutions below

1
On

making discoverable forever -

Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0); startActivity(discoverableIntent);

a value of 0 means the device is always discoverable.

I know, this was posted 2 months back. But there was no answer anyway, so i just thought of replying. :) Hope it helps you.