Am trying to listen for sensor changes of Android auto through Desktop Head Unit with the following code
val carHardwareManager = CarHardwareManager.create(carContext, HostDispatcher())
val sensors = carHardwareManager.carSensors
sensors.addAccelerometerListener(
CarSensors.UPDATE_RATE_NORMAL, { }
) {
Log.d(TAG, "onGetTemplate: Accelerometer statues = ${it.forces.status}")
Log.d(TAG, "onGetTemplate: Accelerometer value = ${it.forces.value}")
}
But am getting this error
java.lang.RuntimeException: androidx.car.app.HostException: Remote subscribeCarHardwareResult call failed
at androidx.car.app.utils.RemoteUtils.lambda$dispatchCallFromHost$0(RemoteUtils.java:155)
at androidx.car.app.utils.RemoteUtils$$ExternalSyntheticLambda1.run(Unknown Source:6)
at androidx.car.app.utils.ThreadUtils.runOnMain(ThreadUtils.java:39)
at androidx.car.app.utils.RemoteUtils.dispatchCallFromHost(RemoteUtils.java:147)
at androidx.car.app.utils.RemoteUtils.lambda$dispatchCallFromHost$1(RemoteUtils.java:186)
at androidx.car.app.utils.RemoteUtils$$ExternalSyntheticLambda2.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8057)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
As the documentation states, I enabled the sensors in the configuration file nad launched the DHU with it. But how to use their command. for example accel [x] [y] [z]
where I use this command for example?