Share via


BluetoothDevice Class

Definition

Represents a remote Bluetooth device.

[Android.Runtime.Register("android/bluetooth/BluetoothDevice", DoNotGenerateAcw=true)]
public sealed class BluetoothDevice : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/bluetooth/BluetoothDevice", DoNotGenerateAcw=true)>]
type BluetoothDevice = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
BluetoothDevice
Attributes
Implements

Remarks

Represents a remote Bluetooth device. A BluetoothDevice lets you create a connection with the respective device or query information about it, such as the name, address, class, and bonding state.

This class is really just a thin wrapper for a Bluetooth hardware address. Objects of this class are immutable. Operations on this class are performed on the remote Bluetooth hardware address, using the BluetoothAdapter that was used to create this BluetoothDevice.

To get a BluetoothDevice, use BluetoothAdapter#getRemoteDevice(String) BluetoothAdapter.getRemoteDevice(String) to create one representing a device of a known MAC address (which you can get through device discovery with BluetoothAdapter) or get one from the set of bonded devices returned by BluetoothAdapter#getBondedDevices() BluetoothAdapter.getBondedDevices(). You can then open a BluetoothSocket for communication with the remote device, using #createRfcommSocketToServiceRecord(UUID) over Bluetooth BR/EDR or using #createL2capChannel(int) over Bluetooth LE.

<div class="special reference">

<h3>Developer Guides</h3>

For more information about using Bluetooth, read the Bluetooth developer guide. </div>

Java documentation for android.bluetooth.BluetoothDevice.

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.

Fields

ActionAclConnected

Broadcast Action: Indicates a low level (ACL) connection has been established with a remote device.

ActionAclDisconnected

Broadcast Action: Indicates a low level (ACL) disconnection from a remote device.

ActionAclDisconnectRequested

Broadcast Action: Indicates that a low level (ACL) disconnection has been requested for a remote device, and it will soon be disconnected.

ActionAliasChanged

Broadcast Action: Indicates the alias of a remote device has been changed.

ActionBondStateChanged

Broadcast Action: Indicates a change in the bond state of a remote device.

ActionClassChanged

Broadcast Action: Bluetooth class of a remote device has changed.

ActionFound

Broadcast Action: Remote device discovered.

ActionNameChanged

Broadcast Action: Indicates the friendly name of a remote device has been retrieved for the first time, or changed since the last retrieval.

ActionPairingRequest

Broadcast Action: This intent is used to broadcast PAIRING REQUEST

ActionUuid

Broadcast Action: This intent is used to broadcast the UUID wrapped as a android.os.ParcelUuid of the remote device after it has been fetched.

AddressTypeAnonymous
Obsolete.

Address type used to indicate an anonymous advertisement.

AddressTypePublic
Obsolete.

Hardware MAC Address of the device

AddressTypeRandom
Obsolete.

Address is either resolvable, non-resolvable or static.

AddressTypeUnknown
Obsolete.

Address type is unknown or unavailable

DeviceTypeClassic
Obsolete.

Bluetooth device type, Classic - BR/EDR devices

DeviceTypeDual
Obsolete.

Bluetooth device type, Dual Mode - BR/EDR/LE

DeviceTypeLe
Obsolete.

Bluetooth device type, Low Energy - LE-only

DeviceTypeUnknown
Obsolete.

Bluetooth device type, Unknown

Error

Sentinel error value for this class.

ExtraBondState

Used as an int extra field in #ACTION_BOND_STATE_CHANGED intents.

ExtraClass

Used as a Parcelable BluetoothClass extra field in #ACTION_FOUND and #ACTION_CLASS_CHANGED intents.

ExtraDevice

Used as a Parcelable BluetoothDevice extra field in every intent broadcast by this class.

ExtraIsCoordinatedSetMember

Used as a boolean extra field in #ACTION_FOUND intents.

ExtraName

Used as a String extra field in #ACTION_NAME_CHANGED and #ACTION_FOUND intents.

ExtraPairingKey

Used as an int extra field in #ACTION_PAIRING_REQUEST intents as the value of passkey.

ExtraPairingVariant

Used as an int extra field in #ACTION_PAIRING_REQUEST intents to indicate pairing method used.

ExtraPreviousBondState

Used as an int extra field in #ACTION_BOND_STATE_CHANGED intents.

ExtraRssi

Used as an optional short extra field in #ACTION_FOUND intents.

ExtraTransport

Used as an int extra field in #ACTION_ACL_CONNECTED and #ACTION_ACL_DISCONNECTED intents to indicate which transport is connected.

ExtraUuid

Used as an extra field in #ACTION_UUID intents, Contains the android.os.ParcelUuids of the remote device which is a parcelable version of UUID.

PairingVariantPasskeyConfirmation

The user will be prompted to confirm the passkey displayed on the screen or an app will confirm the passkey for the user.

PairingVariantPin

The user will be prompted to enter a pin or an app will enter a pin for user.

Properties

Address

Returns the hardware address of this BluetoothDevice.

AddressType

Returns the address type of this BluetoothDevice, one of ADDRESS_TYPE_PUBLIC, ADDRESS_TYPE_RANDOM, ADDRESS_TYPE_ANONYMOUS, or ADDRESS_TYPE_UNKNOWN.

Alias

Get the locally modifiable name (alias) of the remote Bluetooth device.

BluetoothClass

Get the Bluetooth class of the remote device.

BondState

Get the bond state of the remote device.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Name

Get the friendly Bluetooth name of the remote device.

PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
Type

Get the Bluetooth device type of the remote device.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
ConnectGatt(Context, Boolean, BluetoothGattCallback, BluetoothTransports, BluetoothPhy, Handler)

Connect to GATT Server hosted by this device.

ConnectGatt(Context, Boolean, BluetoothGattCallback, BluetoothTransports, BluetoothPhy)

Connect to GATT Server hosted by this device.

ConnectGatt(Context, Boolean, BluetoothGattCallback, BluetoothTransports, ScanSettingsPhy, Handler)
ConnectGatt(Context, Boolean, BluetoothGattCallback, BluetoothTransports, ScanSettingsPhy)
ConnectGatt(Context, Boolean, BluetoothGattCallback, BluetoothTransports)

Connect to GATT Server hosted by this device.

ConnectGatt(Context, Boolean, BluetoothGattCallback)

Connect to GATT Server hosted by this device.

CreateBond()

Start the bonding (pairing) process with the remote device.

CreateInsecureL2capChannel(Int32)

Create a Bluetooth L2CAP Connection-oriented Channel (CoC) BluetoothSocket that can be used to start a secure outgoing connection to the remote device with the same dynamic protocol/service multiplexer (PSM) value.

CreateInsecureRfcommSocketToServiceRecord(UUID)

Create an RFCOMM BluetoothSocket socket ready to start an insecure outgoing connection to this remote device using SDP lookup of uuid.

CreateL2capChannel(Int32)

Create a Bluetooth L2CAP Connection-oriented Channel (CoC) BluetoothSocket that can be used to start a secure outgoing connection to the remote device with the same dynamic protocol/service multiplexer (PSM) value.

CreateRfcommSocketToServiceRecord(UUID)

Create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device using SDP lookup of uuid.

DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FetchUuidsWithSdp()

Perform a service discovery on the remote device to get the UUIDs supported.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetUuids()

Returns the supported features (UUIDs) of the remote device.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetAlias(String)

Sets the locally modifiable name (alias) of the remote Bluetooth device.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPairingConfirmation(Boolean)

Confirm passkey for #PAIRING_VARIANT_PASSKEY_CONFIRMATION pairing.

SetPin(Byte[])

Set the pin during pairing when the pairing method is #PAIRING_VARIANT_PIN

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to