Professional Documents
Culture Documents
How To Enable The Bluetooth For Your Android App
How To Enable The Bluetooth For Your Android App
The difference is that the first function makes the app ask the user a permission to turn on
the Bluetooth or to deny. The second function makes the app turn on the Bluetooth directly.
To Disable the Bluetooth use the following function:
public void disableBT(View view){
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter.isEnabled()){
mBluetoothAdapter.disable();
}
}
NOTE/ The first function needs only the following permission to be defined in the
AndroidManifest.xml file:
<uses-permission android:name="android.permission.BLUETOOTH"/>
While, the second and third functions need the following permissions:
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>