Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Resolver

interface Resolver<T : Any!>
androidx.concurrent.futures.CallbackToFutureAdapter.Resolver

This interface should be implemented by the object passed into getFuture(Resolver).

Implementations are responsible to resolve passed Completer object to success or failure inline or in the response to some other callback.

This interface creates a logical scope for the code that resolves a future returned from getFuture(Resolver) and separates it from outer scope that works with that future as adding listeners etc. This separation allows us to detect situations when the returned future isn't done, but the completer object was garbage collected, and fail the future appropriately instead of keeping the future and its listeners chain forever.

Summary

Public methods

abstract Any?

Create your callback object and start whatever operations are required to trigger it here.

Public methods

attachCompleter

@Nullable abstract fun attachCompleter(@NonNull completer: CallbackToFutureAdapter.Completer<T>): Any?

Create your callback object and start whatever operations are required to trigger it here.

Parameters
completer CallbackToFutureAdapter.Completer<T>: Call one of the set methods on this object to complete the returned Future.
Return
Any?: an object to use as the human-readable description of what is expected to complete this future. In error cases, its toString() will be included in the message.