Language

CompanionDeviceManager Class

Definition

Public interfaces for managing companion devices.

[Android.Runtime.Register("android/companion/CompanionDeviceManager", ApiSince=26, DoNotGenerateAcw=true)]
public sealed class CompanionDeviceManager : Java.Lang.Object
[<Android.Runtime.Register("android/companion/CompanionDeviceManager", ApiSince=26, DoNotGenerateAcw=true)>]
type CompanionDeviceManager = class
    inherit Object
Inheritance
CompanionDeviceManager
Attributes

Remarks

Public interfaces for managing companion devices.

The interfaces in this class allow companion apps to #associate(AssociationRequest, Executor, Callback) discover and request device profiles} for companion devices, #startObservingDevicePresence(String) listen to device presence events, #startSystemDataTransfer(int, Executor, OutcomeReceiver) transfer system level data via #attachSystemDataTransport(int, InputStream, OutputStream) the reported channel and more.

<div class="special reference"> <h3>Developer Guides</h3>

For more information about managing companion devices, read the Companion Device Pairing developer guide. </div>

Java documentation for android.companion.CompanionDeviceManager.

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

Name Description
ErrorTrustOutOfBandPairingFailed
Obsolete.

The out of band pairing failed.

ErrorTrustPairingAssociationDoesNotExist
Obsolete.

The association does not exist.

ErrorTrustPairingCanceled
Obsolete.

The trust pairing dialog was cancelled by the user or implicitly.

ErrorTrustPairingFailedToCreatePairingDialog
Obsolete.

Failed to create or send pairing dialog for trust pairing.

ErrorTrustPairingPinCodeNotMatching
Obsolete.

The PIN code confirmed by the user did not match.

ErrorTrustPairingTransportNotAttached
Obsolete.

The transport was not attached for trust pairing.

ErrorTrustResumptionFailed
Obsolete.

The trust resumption failed.

ErrorTrustUnknown
Obsolete.

Unknown error for trust pairing.

ExtraAssociation

Extra field name for the AssociationInfo object, included into android.content.Intent which application receive in Activity#onActivityResult(int, int, Intent) after the application's AssociationRequest was successfully processed and an association was created.

ExtraDevice

A device, returned in the activity result of the IntentSender received in Callback#onDeviceFound

        Type is:
        &lt;ul&gt;
            &lt;li&gt;for classic Bluetooth - <code data-dev-comment-type="c">android.bluetooth.BluetoothDevice</code>&lt;/li&gt;
            &lt;li&gt;for Bluetooth LE - <code data-dev-comment-type="c">android.bluetooth.le.ScanResult</code>&lt;/li&gt;
            &lt;li&gt;for WiFi - <code data-dev-comment-type="c">android.net.wifi.ScanResult</code>&lt;/li&gt;
        &lt;/ul&gt;
FlagAirplaneMode
Obsolete.

Used by EnableSystemDataSyncForTypes(Int32, SystemDataSyncFlags).

FlagCallMetadata
Obsolete.

Used by #enableSystemDataSyncForTypes(int, int)}.

FlagTaskContinuity
Obsolete.

Used by EnableSystemDataSyncForTypes(Int32, SystemDataSyncFlags).

FlagUniversalModes
Obsolete.

Used by EnableSystemDataSyncForTypes(Int32, SystemDataSyncFlags).

ResultCanceled
Obsolete.

The result code to propagate back to the user activity, indicates if the association dialog is implicitly cancelled.

ResultDiscoveryTimeout
Obsolete.

The result code to propagate back to the user activity, indicates the association dialog is dismissed if there's no device found after 20 seconds.

ResultInternalError
Obsolete.

The result code to propagate back to the user activity, indicates the internal error in CompanionDeviceManager.

ResultOk
Obsolete.

The result code to propagate back to the user activity, indicates the association is created successfully.

ResultSecurityError
Obsolete.

The result code to propagate back to the user activity and Callback#onFailure(int, CharSequence), indicates app is not allow to create the association due to the security issue.

ResultUserRejected
Obsolete.

The result code to propagate back to the user activity, indicates the association dialog is explicitly declined by the users.

TrustTypeCrossDeviceAuthentication
Obsolete.

Trust type for platform-level cross-device authentication.

TrustTypeProactiveAssistance
Obsolete.

Trust type for proactive assistance.

TrustTypeScreenAutomation
Obsolete.

Trust type for screen automation.

Properties

Name Description
Associations

Calling this API requires a uses-feature PackageManager#FEATURE_COMPANION_DEVICE_SETUP declaration in the manifest

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the Java identity hash code stored for this peer.

(Inherited from Object)
JniManagedPeerState

Gets the state flags last assigned by the runtime.

(Inherited from JavaObject)
JniPeerMembers

Gets the JNI metadata used to access members of this Java binding.

MyAssociations

Calling this API requires a uses-feature PackageManager#FEATURE_COMPANION_DEVICE_SETUP declaration in the manifest

PeerReference

Gets the JNI object reference for this Java peer.

(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)

Methods

Name Description
Associate(AssociationRequest, CompanionDeviceManager+Callback, Handler)

Associate this app with a companion device, selected by user

Associate(AssociationRequest, IExecutor, CompanionDeviceManager+Callback)

Request to associate this app with a companion device.

AttachSystemDataTransport(Int32, Stream, Stream)

Attach a bidirectional communication stream to be used as a transport channel for transporting system data between associated devices.

BuildAssociationCancellationIntent()

Cancel the current association activity.

BuildPermissionTransferUserConsentIntent(Int32)

Build a permission sync user consent dialog.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions)

Delegates construction of this peer to the runtime's value manager.

(Inherited from JavaObject)
CreateAndSetDeviceId(Int32, DeviceId)

Returns a new DeviceId which can be passed to device manufacturers' apps, allowing them to fetch AssociationInfo or observe device presence for this associated device.

DetachSystemDataTransport(Int32)

Detach the transport channel that's previously attached for the associated device.

DisableSystemDataSyncForTypes(Int32, SystemDataSyncFlags)

Disable system data sync for an associated device.

Disassociate(Int32)

Remove an association.

Disassociate(String)

Remove the association between this app and the device with the given mac address.

Dispose()

Releases the JNI reference held by this managed peer and unregisters the peer from the interop runtime.

(Inherited from Object)
Dispose(Boolean)

Provides a disposal hook for subclasses. This implementation performs no action.

(Inherited from Object)
DisposeUnlessReferenced()

Asks the value manager to dispose this peer unless its mapping retains this same managed instance.

(Inherited from JavaObject)
EnableSystemDataSyncForTypes(Int32, SystemDataSyncFlags)

Enable system data sync for an associated device.

Equals(Object)

Tests whether another managed peer refers to the same Java object.

(Inherited from JavaObject)
Equals(Object)

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

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
HasNotificationAccess(ComponentName)

Check whether the given component can access the notifications via a NotificationListenerService

        Your app must have an association with a device before calling this API
IsPermissionTransferUserConsented(Int32)

Return the current state of consent for permission transfer for the association.

IsSystemDataTransportAttached(Int32)

Checks if a transport is currently attached for a given association id.

JavaFinalize()
Obsolete.

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)
NotifyActionResult(Int32, ActionResult)

Allows a companion app to report the result of an action that was requested by the system.

NotifyAll()

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

(Inherited from Object)
RemoveBond(Int32)

Remove bonding between this device and an associated companion device.

RequestDeviceTrustPairing(Int32, OutOfBandPairingRequest, Int32[], IExecutor, CompanionDeviceManager+TrustPairingCallback)

Request the system to initiate a trusted pairing process for the given association.

RequestNotificationAccess(ComponentName)

Request notification access for the given component.

SetDeviceId(Int32, DeviceId)

Sets the DeviceId deviceId for this association.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions)

Stores a reference value in the control block without creating a JNI reference copy.

(Inherited from JavaObject)
StartObservingDevicePresence(ObservingDevicePresenceRequest)

Register to receive callbacks whenever an observed device's presence changes.

StartObservingDevicePresence(String)

Register to receive callbacks whenever the associated device comes in and out of range.

StartSystemDataTransfer(Int32, IExecutor, IOutcomeReceiver)

Start system data transfer which has been previously approved by the user.

StopObservingDevicePresence(ObservingDevicePresenceRequest)

Unregister for receiving callbacks whenever the associated device comes in and out of range.

StopObservingDevicePresence(String)

Unregister for receiving callbacks whenever the associated device comes in and out of range.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

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

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, 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 notified or interrupted, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed()

Marks this peer as disposed and calls Dispose with disposing set to true.

(Inherited from JavaObject)
IJavaPeerable.Finalized()

Marks this peer as disposed and calls Dispose with disposing set to false.

(Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock

Gets the native control-block pointer used by this peer.

(Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32)

Stores the identity hash code supplied by the runtime.

(Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

Replaces the stored managed peer state flags.

(Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference)

Updates the peer reference and releases a disposed peer's control block when the reference is invalid.

(Inherited from JavaObject)

Extension Methods

Name Description
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.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)

Reuses a compatible managed peer or obtains a wrapper of the requested type.

TryJavaCast<TResult>(IJavaPeerable, TResult)

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

Applies to