- Create a Car object example
mCar
and call mCar = Car.createCar(this);
when the application is loading.
- Create a CarPropertyManager object example
mCarPropertyManager
and instantiate it by writing mCarPropertyManager = car.getCarManager(Car.PROPERTY_SERVICE);
.
- Create a listener for VIN information event as
vinCarPropertyListener
.
- Register for any event. In your case, its Car VIN.
`carPropertyManager.registerCallback(vinCarPropertyListener, VehiclePropertyIds.INFO_VIN)
- In
onEventChanged()
, you will receive the VIN as CarPropertyValue
.
override fun onChangeEvent(value: CarPropertyValue<Any>) {
Log.d(TAG, "Received on changed car property event")
// value.value type changes depending on the vehicle property.
Log.d(TAG, "VIN value: ${value.value}")
}
Reference link: CarPropertyExample
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…