Android: Set Bluetooth Discoverability Unbounded

前端 未结 6 1673
悲&欢浪女
悲&欢浪女 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

    above api level 14 EXTRA_DISCOVERABLE_DURATION 0 works with infinite limit but below this it works for max 1 hour.

    This code works for me

    Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
    intent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
    startActivityForResult(intent, Utils.REQUEST_DEVICE_DISCOVERABLE);
    

提交回复
热议问题