简体   繁体   中英

How to programmatically enable or disable Bluetooth Profiles in Android?

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?

Just try enabling or disabling Bluetooth.

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

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

Try

Get default bluetooth adapter

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

Enable

 bluetoothAdapter.enable(); 

Disable

bluetoothAdapter.disable(); 

Check Status

bluetoothAdapter.isEnabled();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM