0

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?

4

1 回答 1

1

我参加聚会已经很晚了,但对于可能需要这个的人来说仍然很晚。您可以使设备发现的最大值仅为 300 秒。根据以下文档:

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"
于 2015-02-11T08:48:16.633 回答