Skip to main content

Obtaining a domain object

Vehicle SDK APIs are used by obtaining a domain object from the Vehicle entry point and then calling one of four types of APIs (Get, Set, Callback, Capability) on that object. See Introduction for the domain structure. For permissions, see Permission. For error handling, see Error code.

Create a Vehicle instance and connect to the vehicle service with initialize(), then obtain a domain object via a getXxx() method such as getDoor() or getDisplay(). Call Get, Set, Callback, and Capability APIs on the domain object, and release resources with release() when finished.

Because vehicle communication uses IPC, get, set, and capability results are not returned synchronously; they are delivered via asynchronous onComplete and onFailed callbacks. Do not call release() before those callbacks complete.

// Create and initialize the Vehicle instance
val vehicle = Vehicle(context)
vehicle.initialize()

// Obtain a domain object via getXxx()
val door = vehicle.getDoor()

// Call Get / Set / Callback / Capability APIs on the door object
// ...

// Release resources when finished
vehicle.release()

The four API types

TypeWhat it doesResult deliveryDoc
CapabilityCheck feature support and allowed rangesonComplete(config, areaMap) / onFailedCapability
GetRead the current valueonComplete(value) / onFailedGet
SetWrite a valueonFailed (on failure)Set
CallbackSubscribe to state changeslistener onXxxUpdated / onFailedCallback

The API type examples assume the Vehicle instance (vehicle) has already been initialized.