From the Android API Guide > Bluetooth > Enabling discoverability:
The maximum duration an app can set is 3600 seconds, and a value of 0 means the device is always discoverable. Any value below 0 or above 3600 is automatically set to 120 secs). For example, this snippet sets the duration to 300:
So I want to make the device always discoverable, and use their code snippet:
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
startActivity(discoverableIntent);
While the snippet correctly shows the user a dialog that asks their permission to make their device "always visible to other bluetooth devices", pressing "Yes" will only make the device discoverable for 120 seconds.
Is this a bug? What can I do about it? I'm testing on API 17, with a Samsung Galaxy S2.
Edit:
Extend Android Bluetooth Discoverability
Here it is suggested in one of the answers that this goes beyond Android, and that this issue has to do with the DiscoverableTimeout
value in /system/etc/bluetooth/main.conf
. Is this true? If so, how would I edit the value?