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?
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