Bluetooth permanent discoverability not working

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?


I am quite late for the party , but still for someone who might need this. Maximum you can make device discover able is only for 300 seconds. As per following docs:

public static final String EXTRA_DISCOVERABLE_DURATION

Added in API level 5
Used as an optional int extra field in ACTION_REQUEST_DISCOVERABLE intents to request a specific duration for discoverability in seconds. The current default is 120 seconds, and requests over 300 seconds will be capped. These values could change.

Constant Value: "android.bluetooth.adapter.extra.DISCOVERABLE_DURATION"
链接地址: http://www.djcxy.com/p/26928.html

上一篇: 警报对话框在旋转屏幕时关闭

下一篇: 蓝牙永久可发现性不起作用