Language

CompanionDeviceManager.CreateAndSetDeviceId(Int32, DeviceId) Method

Definition

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.

[Android.Runtime.Register("createAndSetDeviceId", "(ILandroid/companion/DeviceId;)Landroid/companion/DeviceId;", "", ApiSince=36)]
public Android.Companion.DeviceId? CreateAndSetDeviceId(int associationId, Android.Companion.DeviceId? deviceId);
[<Android.Runtime.Register("createAndSetDeviceId", "(ILandroid/companion/DeviceId;)Landroid/companion/DeviceId;", "", ApiSince=36)>]
member this.CreateAndSetDeviceId : int * Android.Companion.DeviceId -> Android.Companion.DeviceId

Parameters

associationId
Int32

The unique AssociationInfo#getId assigned to the Association of the companion device recorded by CompanionDeviceManager.

deviceId
DeviceId

to be used as device identifier to represent the associated device.

Returns

Attributes

Remarks

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. This method creates a new object and does not mutate any existing DeviceId.

The system will generate and assign a new, random 128-bit key to this returned DeviceId. Each call to this method generates a new key, any previously associated key will be obsoleted. Therefore, the returned DeviceId is the one that contains the newly assigned key and should be used for subsequent operations.

This device id also helps the system uniquely identify your device for efficient device management and prevents duplicate entries.

WARNING: Do not pass the returned DeviceId to apps you do not trust.

Java documentation for android.companion.CompanionDeviceManager.createAndSetDeviceId(int, android.companion.DeviceId).

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.

Applies to