ProjectedDeviceController


@ExperimentalProjectedApi
class ProjectedDeviceController : AutoCloseable


Controller for the Projected device.

Use create to create an instance of this class. Call close when finished with this instance to release resources.

Summary

Nested types

Represents an intrinsic piece of functionality of a Projected device, i.e., what it is capable of.

Public companion functions

suspend ProjectedDeviceController
@RequiresApi(value = 34)
create(context: Context)

Connects to the service providing features for Projected devices and returns the ProjectedDeviceController when the connection is established.

Public functions

Unit
addBatteryStateChangedListener(
    context: CoroutineContext,
    listener: (BatteryState) -> Unit
)

Adds a listener for battery state changes.

open Unit

Releases resources, unregistering any active listeners.

Unit

Removes a previously added listener.

Public properties

List<AudioDeviceInfo>

Returns the list of AudioDeviceInfo objects associated with the projected device.

Set<ProjectedDeviceController.Capability>

The capabilities of the Projected device.

Public companion functions

create

@RequiresApi(value = 34)
suspend fun create(context: Context): ProjectedDeviceController

Connects to the service providing features for Projected devices and returns the ProjectedDeviceController when the connection is established. The caller is responsible for calling close on the returned instance when it's no longer needed to release all internal resources.

Parameters
context: Context

The context to use for binding to the service.

Throws
IllegalStateException

if the projected service is not found or binding is not permitted

Public functions

addBatteryStateChangedListener

Added in 1.0.0-alpha09
fun addBatteryStateChangedListener(
    context: CoroutineContext,
    listener: (BatteryState) -> Unit
): Unit

Adds a listener for battery state changes.

The listener lambda will be executed in a new coroutine launched within the provided context. The listener will be automatically unregistered when the context's Job is canceled.

close

Added in 1.0.0-alpha09
open fun close(): Unit

Releases resources, unregistering any active listeners. This instance should not be used after calling close.

removeBatteryStateChangedListener

Added in 1.0.0-alpha09
fun removeBatteryStateChangedListener(listener: (BatteryState) -> Unit): Unit

Removes a previously added listener. Note: Listeners are also automatically removed when their associated CoroutineScope is canceled.

Public properties

audioDevices

Added in 1.0.0-alpha09
val audioDevicesList<AudioDeviceInfo>

Returns the list of AudioDeviceInfo objects associated with the projected device.

capabilities

Added in 1.0.0-alpha09
val capabilitiesSet<ProjectedDeviceController.Capability>

The capabilities of the Projected device.

These capabilities represent intrinsic functionality of the device that will not change over the lifetime of the device, for example, whether the device is capable of showing a visual user interface at all, regardless of whether the screen is currently on or off.