蓝牙永久可发现性不起作用

时间:2013-11-01 13:29:22

标签: android bluetooth android-bluetooth

来自Android API Guide > Bluetooth > Enabling discoverability

  

应用可设置的最长持续时间为3600秒,,值为0表示设备始终可被发现。任何低于0或高于3600的值都会自动设置为120秒。例如,此代码段将持续时间设置为300:

所以我想让设备始终可被发现,并使用他们的代码片段:

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

虽然该片段正确地向用户显示一个对话框,要求他们允许他们的设备“始终对其他蓝牙设备可见”,但按“是”只会使设备可被发现120秒。

这是一个错误吗?我能做些什么呢?我正在测试API 17,使用三星Galaxy S2。

修改

Extend Android Bluetooth Discoverability

在其中一个答案中建议这超出了Android,并且此问题与DiscoverableTimeout中的/system/etc/bluetooth/main.conf值有关。这是真的?如果是这样,我将如何编辑值?

1 个答案:

答案 0 :(得分: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"