Android: Set Bluetooth Discoverability Unbounded

前端 未结 6 1634
悲&欢浪女
悲&欢浪女 2021-01-06 23:57

I have spent the last couple of days trying to make an app that keeps my Samsung Galaxy S3 mini (Android 2.1.4) discoverable for an \"infinite\" amount of time. My code look

6条回答
  •  时光说笑
    2021-01-07 00:14

    According to Android documentation, the maximum time for being discoverable is capped at 300seconds. You cannot make the BT discoverable forever.

    Please see: http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#ACTION_REQUEST_DISCOVERABLE

    In order to get the 300second maximum period, you need to change one line of code as:

    MDisc.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,300)
    

提交回复
热议问题