【问题标题】:Bluetooth permanent discoverability not working蓝牙永久可发现性不起作用
【发布时间】:2015-02-11 16:48:16
【问题描述】:

来自Android API Guide > Bluetooth > Enabling discoverability

应用可以设置的最长持续时间为 3600 秒,值为 0 表示设备始终可被发现。任何低于 0 或高于 3600 的值都会自动设置为 120 秒)。例如,这个 sn -p 将持续时间设置为 300:

所以我想让设备始终可发现,并使用他们的代码 sn-p:

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

虽然 sn-p 正确地向用户显示了一个对话框,询问他们是否允许他们的设备“始终对其他蓝牙设备可见”,但按“是”只会让设备在 120 秒内可被发现。

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

编辑:

Extend Android Bluetooth Discoverability

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

【问题讨论】:

  • 您为什么希望它在几分钟内被发现?
  • 这有关系吗?我只想使用提到的功能,不管这是否可取。

标签: android bluetooth android-bluetooth


【解决方案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"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-01
    • 2016-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多