Android Guides | Samples

Android.Bluetooth.BluetoothAdapter Class

Represents the local device Bluetooth adapter.

See Also: BluetoothAdapter

Syntax

[Android.Runtime.Register("android/bluetooth/BluetoothAdapter", DoNotGenerateAcw=true)]
public sealed class BluetoothAdapter : Object

Remarks

Represents the local device Bluetooth adapter. The BluetoothAdapter lets you perform fundamental Bluetooth tasks, such as initiate device discovery, query a list of bonded (paired) devices, instantiate a BluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for connection requests from other devices, and start a scan for Bluetooth LE devices.

To get a BluetoothAdapter representing the local Bluetooth adapter, when running on JELLY_BEAN_MR1 and below, call the static BluetoothAdapter.DefaultAdapter method; when running on JELLY_BEAN_MR2 and higher, retrieve it through Context.GetSystemService(String) with Context.BluetoothService. Fundamentally, this is your starting point for all Bluetooth actions. Once you have the local adapter, you can get a set of BluetoothDevice objects representing all paired devices with BluetoothAdapter.BondedDevices; start device discovery with BluetoothAdapter.StartDiscovery; or create a BluetoothServerSocket to listen for incoming connection requests with BluetoothAdapter.ListenUsingRfcommWithServiceRecord(String,UUID); or start a scan for Bluetooth LE devices with BluetoothAdapter.StartLeScan(.ILeScanCallback).

Note: Most methods require the NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#BLUETOOTH permission and some also require the NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#BLUETOOTH_ADMIN permission.

Developer Guides

For more information about using Bluetooth, read the Bluetooth developer guide.

See Also

[Android Documentation]

Requirements

Namespace: Android.Bluetooth
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 5

The members of Android.Bluetooth.BluetoothAdapter are listed below.

See Also: Object

Public Fields

const
ActionConnectionStateChangedString. Intent used to broadcast the change in connection state of the local Bluetooth adapter to a profile of the remote device.
const
ActionDiscoveryFinishedString. Broadcast Action: The local Bluetooth adapter has finished the device discovery process.
const
ActionDiscoveryStartedString. Broadcast Action: The local Bluetooth adapter has started the remote device discovery process.
const
ActionLocalNameChangedString. Broadcast Action: The local Bluetooth adapter has changed its friendly Bluetooth name.
const
ActionRequestDiscoverableString. Activity Action: Show a system activity that requests discoverable mode.
const
ActionRequestEnableString. Activity Action: Show a system activity that allows the user to turn on Bluetooth.
const
ActionScanModeChangedString. Broadcast Action: Indicates the Bluetooth scan mode of the local Adapter has changed.
const
ActionStateChangedString. Broadcast Action: The state of the local Bluetooth adapter has been changed.
const
ErrorInt32 (-2147483648). Sentinel error value for this class.
const
ExtraConnectionStateString. Extra used by BluetoothAdapter.ActionConnectionStateChanged This extra represents the current connection state.
const
ExtraDiscoverableDurationString. Used as an optional int extra field in BluetoothAdapter.ActionRequestDiscoverable intents to request a specific duration for discoverability in seconds.
const
ExtraLocalNameString. Used as a String extra field in BluetoothAdapter.ActionLocalNameChanged intents to request the local Bluetooth name.
const
ExtraPreviousConnectionStateString. Extra used by BluetoothAdapter.ActionConnectionStateChanged This extra represents the previous connection state.
const
ExtraPreviousScanModeString. Used as an int extra field in BluetoothAdapter.ActionScanModeChanged intents to request the previous scan mode.
const
ExtraPreviousStateString. Used as an int extra field in BluetoothAdapter.ActionStateChanged intents to request the previous power state.
const
ExtraScanModeString. Used as an int extra field in BluetoothAdapter.ActionScanModeChanged intents to request the current scan mode.
const
ExtraStateString. Used as an int extra field in BluetoothAdapter.ActionStateChanged intents to request the current power state.

Public Properties

[read-only]
AddressString. Returns the hardware address of the local Bluetooth adapter.
[read-only]
BluetoothLeAdvertiserBluetoothLeAdvertiser. Returns a BluetoothLeAdvertiser object for Bluetooth LE Advertising operations.
[read-only]
BluetoothLeScannerBluetoothLeScanner. Returns a BluetoothLeScanner object for Bluetooth LE scan operations.
[read-only]
BondedDevicesICollection<BluetoothDevice>. Return the set of BluetoothDevice objects that are bonded (paired) to the local adapter.
[read-only]
static
DefaultAdapterBluetoothAdapter. Get a handle to the default local Bluetooth adapter.
[read-only]
IsDiscoveringBoolean. Return true if the local Bluetooth adapter is currently in the device discovery process.
[read-only]
IsEnabledBoolean. Return true if Bluetooth is currently enabled and ready for use.
[read-only]
IsMultipleAdvertisementSupportedBoolean. Return true if the multi advertisement is supported by the chipset
[read-only]
IsOffloadedFilteringSupportedBoolean. Return true if offloaded filters are supported
[read-only]
IsOffloadedScanBatchingSupportedBoolean. Return true if offloaded scan batching is supported
[read-only]
NameString. Get the friendly Bluetooth name of the local Bluetooth adapter.
[read-only]
ScanModeScanMode. Get the current Bluetooth scan mode of the local Bluetooth adapter.
[read-only]
StateState. Get the current state of the local Bluetooth adapter.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

CancelDiscovery() : Boolean
Cancel the current device discovery process.
static
CheckBluetoothAddress(String) : Boolean
Validate a String Bluetooth address, such as "00:43:A8:23:10:F0"
CloseProfileProxy(ProfileType, IBluetoothProfile)
Close the connection of the profile proxy to the Service.
Disable() : Boolean
Turn off the local Bluetooth adapter&mdash;do not use without explicit user action to turn off Bluetooth.
Enable() : Boolean
Turn on the local Bluetooth adapter&mdash;do not use without explicit user action to turn on Bluetooth.
GetProfileConnectionState(ProfileType) : ProfileState
Get the current connection state of a profile.
GetProfileProxy(Context, IBluetoothProfileServiceListener, ProfileType) : Boolean
Get the profile proxy object associated with the profile.
GetRemoteDevice(Byte[]) : BluetoothDevice
Get a BluetoothDevice object for the given Bluetooth hardware address.
GetRemoteDevice(String) : BluetoothDevice
Get a BluetoothDevice object for the given Bluetooth hardware address.
ListenUsingInsecureRfcommWithServiceRecord(String, UUID) : BluetoothServerSocket
Create a listening, insecure RFCOMM Bluetooth socket with Service Record.
ListenUsingRfcommWithServiceRecord(String, UUID) : BluetoothServerSocket
Create a listening, secure RFCOMM Bluetooth socket with Service Record.
SetName(String) : Boolean
Set the friendly Bluetooth name of the local Bluetooth adapter.
StartDiscovery() : Boolean
Start the remote device discovery process.
StartLeScan(BluetoothAdapter+ILeScanCallback) : Boolean
Starts a scan for Bluetooth LE devices.
StartLeScan(UUID[], BluetoothAdapter+ILeScanCallback) : Boolean
Starts a scan for Bluetooth LE devices, looking for devices that advertise given services.
StopLeScan(BluetoothAdapter+ILeScanCallback)
Stops an ongoing Bluetooth LE device scan.