Currently i am working on a Bluetooth app where i need to change the Scan Mode from SCAN_MODE_CONNECTABLE_DISCOVERABLE
to SCAN_MODE_CONNECTABLE
on click of a button.
i am setting it Discoverable using following Intent:
Intent discoverableIntent = new Intent( BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent .putExtra( BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, DISOVERABLE_DURATION);
startActivityForResult(discoverableIntent, REQUEST_DISCOVERABLE_BT);
where i have set DISOVERABLE_DURATION=300
;
Now i want to skip the Discoverability in between and want to change its state to SCAN_MODE_CONNECTABLE
only.
Kindly provide me an appropriate solution../
Best Answer
Well it is quite old question, however you can switch scan mode of bluetooth without any permission of user and (for as far as i have tested) unlimited time. This will require using reflections on Android API, so this is not an official api. Of course, you are using it on your own risk :) Below is code i am using to make BT adapter discoverable:
Also you need permissions:
After this device should be in scan mode you choose by passing the int scanMode argument. It is working on Android API 23.