Two previous answers to my question from other people got deleted. No idea why, but they gave me the hints I needed to fix the code and get it working.
in the CarAppService implementation, in the
public Session onCreateSession() {
at the end where I do:
return new Session() {
I have a block of code like this:
CarInfo carInfo =
getCarContext().getCarService(CarHardwareManager.class).getCarInfo();
mCarHardwareExecutor = ContextCompat.getMainExecutor(getCarContext());
OnCarDataAvailableListener<Model> mModelListener = data -> {
synchronized (this) {
String statusText = "" + data.getYear().getValue() + " " + data.getManufacturer().getValue() + " " + data.getName().getValue();
theSimpleAAScreen.setStatusText(statusText);
theSimpleAAScreen.invalidate();
}
/* get year, make, model */
try {
carInfo.fetchModel(mCarHardwareExecutor, mModelListener);
} catch (SecurityException e) {
Log.e(TAG, "No permission to get model");
}
theSimpleAAScreen is an object that is the android auto screen: I set a value for what to print and invalidate the screen so it redraws. There is probably a better / smoother way but this works and answers my question.