Udostępnij za pośrednictwem


CompanionDeviceManager.Callback Class

Definition

Callback for applications to receive updates about and the outcome of AssociationRequest issued via associate() call.

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

Remarks

Callback for applications to receive updates about and the outcome of AssociationRequest issued via associate() call.

The Callback#onAssociationPending(IntentSender) is invoked after the AssociationRequest has been checked by the Companion Device Manager Service and is pending user's approval.

The IntentSender received as an argument to Callback#onAssociationPending(IntentSender) "encapsulates" an Activity that has UI for the user to: <ul> <li> choose the device to associate the application with (if multiple eligible devices are available) </li> <li>confirm the association</li> <li> approve the privileges the application will be granted if the association is to be created </li> </ul>

If the Companion Device Manager Service needs to scan for the devices, the Activity will also display the status and the progress of the scan.

Note that Companion Device Manager Service will only start the scanning after the Activity was launched and became visible.

Applications are expected to launch the UI using the received IntentSender via Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int).

Upon receiving user's confirmation Companion Device Manager Service will create an association and will send an AssociationInfo object that represents the created association back to the application both via Callback#onAssociationCreated(AssociationInfo) and via Activity#setResult(int, Intent). In the latter the resultCode will be set to Activity#RESULT_OK and the dataIntent will contain AssociationInfo extra named #EXTRA_ASSOCIATION.

<code>
              if (resultCode == Activity.RESULT_OK) {
                AssociationInfo associationInfo = data.getParcelableExtra(EXTRA_ASSOCIATION);
              }
</code>

</p>

If the Companion Device Manager Service is not able to create an association, it will invoke Callback#onFailure(CharSequence).

If this happened after the application has launched the UI (eg. the user chose to reject the association), the outcome will also be delivered to the applications via Activity#setResult(int) with the Activity#RESULT_CANCELEDresultCode.

Note that in some cases the Companion Device Manager Service may not need to collect user's approval for creating an association. In such cases, this method will not be invoked, and #onAssociationCreated(AssociationInfo) may be invoked right away.

Java documentation for android.companion.CompanionDeviceManager.Callback.

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.

Constructors

CompanionDeviceManager.Callback()
CompanionDeviceManager.Callback(IntPtr, JniHandleOwnership)

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass
ThresholdType

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
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)
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)
OnAssociationCreated(AssociationInfo)

Invoked when the association is created.

OnAssociationPending(IntentSender)

Invoked when the association needs to approved by the user.

OnDeviceFound(IntentSender)

This member is deprecated.

OnFailure(ICharSequence)

Invoked if the association could not be created.

OnFailure(String)

Invoked if the association could not be created.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
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)

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)

Applies to