How to programmatically enable or disable Bluetooth profiles in Android?

I have a requirement where I have a list of paired devices connected via bluetooth to my phone. At some point I have to disable / enable media sharing or contact information with my paired devices. My requirement is to do it programmatically in android. I have searched for this but I could not find any solution for it.

Please let me know if this is possible?

+3


source to share


2 answers


Just try turning Bluetooth on or off.



BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

            if (mBluetoothAdapter.isEnabled()) {
                mBluetoothAdapter.disable(); 
            }else {
                mBluetoothAdapter.enable(); 
            }

      

+1


source


Try

Get default bluetooth adapter

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

      

Enable

 bluetoothAdapter.enable(); 

      



Disable

bluetoothAdapter.disable(); 

      

Check status

bluetoothAdapter.isEnabled();

      

+1


source







All Articles