private void initcar() {
if(!getBaseContext().getPackageManager().hasSystemFeature(getBaseContext().getPackageManager().FEATURE_AUTOMOTIVE)){
Log.d(TAG, "initcar: hasSystemFeature failed");
return;
}
mCar = Car.createCar(this);
carPropertyManager = (CarPropertyManager) mCar.getCarManager(Car.PROPERTY_SERVICE);
mpropertyids = carPropertyManager.getPropertyList();
Log.d(TAG, "initcar: List = " + mpropertyids.size()); // Always returns 0
carPropertyManager.registerCallback(this.carPropertyListener, VehiclePropertyIds.PERF_VEHICLE_SPEED,
CarPropertyManager.SENSOR_RATE_ONCHANGE);
}
public CarPropertyManager.CarPropertyEventCallback carPropertyListener = new CarPropertyManager.CarPropertyEventCallback() {
@Override
public void onChangeEvent(CarPropertyValue carPropertyValue) {
Log.d(TAG, "onChangeEvent: " + carPropertyValue.getValue());
}
@Override
public void onErrorEvent(int i, int i1) {
Log.d(TAG, "onErrorEvent: ");
}
};
When i run this code am getting "CarPropertyManager: registerListener: propId is not in config list: 291504647"
PERF_VEHICLE_SPEED = 291504647
I am assuming we need to add List<CarPropertyConfig> mpropertyids or register it somewhere .
Am not aware how to do this .
Can anyone help me get through this ? I am basically still struggling to see car speed printed in log.