5

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

Please let me know if it is possible?

PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
Vishnu Cyruz
  • 243
  • 1
  • 3
  • 14

2 Answers2

1

Just try enabling or disabling Bluetooth.

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

            if (mBluetoothAdapter.isEnabled()) {
                mBluetoothAdapter.disable(); 
            }else {
                mBluetoothAdapter.enable(); 
            }
Sanju
  • 663
  • 9
  • 20
1

Try

Get default bluetooth adapter

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

Enable

 bluetoothAdapter.enable(); 

Disable

bluetoothAdapter.disable(); 

Check Status

bluetoothAdapter.isEnabled();
PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
  • Thanks for the code you have given. But that is not my requirement. I have to disable the bluetooth profiles such as media, contact details without disabling bluetooth. – Vishnu Cyruz May 09 '17 at 10:38
  • No. I want to disable only the bluetooth profiles. Both bluetooth connection and paired devices need to be there. – Vishnu Cyruz May 09 '17 at 10:43