Setting discoverable mode for bluetooth to always on seam to fail

爷,独闯天下 提交于 2019-12-22 13:51:21

问题


I am trying to set the bluetooth discoverable mode to always on in Android 4.0. This should be possible with 4.0, with the command:

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

After executing this I get a dialog that asks if it is OK to start bluetooth with discoverybility always on. If I press yes the bluetooth setting will show the time 0:00 and it will NOT countdown. So far it looks fine, but after 2 min the bluetooth will change to unvisible mode again (if the previous setting was 2 min). Only if the previous setting was always on (set by manually going into the bluetooth settings) the Intent will work.

Does anyone know more about this? Is this a bug or is it how it is supposed to be? Should it not be possible to change the setting to always on by code?


回答1:


Nothing has changed as per the API docs . See this

It defaults to 120 seconds and max is 300 seconds



来源:https://stackoverflow.com/questions/8837386/setting-discoverable-mode-for-bluetooth-to-always-on-seam-to-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!