BluetoothAdapter.Disable Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Turn off the local Bluetooth adapter—do not use without explicit user action to turn off Bluetooth.
[Android.Runtime.Register("disable", "()Z", "")]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")]
public bool Disable ();
[<Android.Runtime.Register("disable", "()Z", "")>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")>]
member this.Disable : unit -> bool
Returns
true to indicate adapter shutdown has begun, or false on immediate error
- Attributes
Remarks
Turn off the local Bluetooth adapter—do not use without explicit user action to turn off Bluetooth.
This gracefully shuts down all Bluetooth connections, stops Bluetooth system services, and powers down the underlying Bluetooth hardware.
<strong>Bluetooth should never be disabled without direct user consent</strong>. The #disable()
method is provided only for applications that include a user interface for changing system settings, such as a "power manager" app.
This is an asynchronous call: it will return immediately, and clients should listen for #ACTION_STATE_CHANGED
to be notified of subsequent adapter state changes. If this call returns true, then the adapter state will immediately transition from #STATE_ON
to #STATE_TURNING_OFF
, and some time later transition to either #STATE_OFF
or #STATE_ON
. If this call returns false then there was an immediate problem that will prevent the adapter from being turned off - such as the adapter already being turned off.
This member is deprecated. Starting with android.os.Build.VERSION_CODES#TIRAMISU
, applications are not allowed to enable/disable Bluetooth. <b>Compatibility Note:</b> For applications targeting android.os.Build.VERSION_CODES#TIRAMISU
or above, this API will always fail and return false
. If apps are targeting an older SDK (android.os.Build.VERSION_CODES#S
or below), they can continue to use this API. <p>Deprecation Exemptions: <ul> <li>Device Owner (DO), Profile Owner (PO) and system apps. </ul>
Java documentation for android.bluetooth.BluetoothAdapter.disable()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.