I want to test the function
onSensorChanged (SensorEvent event){..}
on the emulator. I want to create a new SensorEvent object. I found a nice link:
http://download.java.net/media/java3d/javadoc/1.5.0/com/sun/j3d/utils/behaviors/sensor/SensorEvent.html#SensorEvent%28java.lang.Object,%20int,%20javax.media.j3d.Sensor,%20javax.media.j3d.Transform3D,%20int[],%20int,%20long,%20long%29
but I don't know how to create argument
Transform3D sensorRead
So, how I create Transform3D object or new SensorEvent one? Thanks.
android.hardware.SensorEvent. This class represents a Sensor event and holds information such as the sensor's type, the time-stamp, accuracy and of course the sensor's data . Definition of the coordinate system used by the SensorEvent API.
onSensorChanged(SensorEvent event) : Called when sensor values have changed.
I don't think this will do you any good. AFAIK, there's no relationship between android.hardware.SensorEvent and com.sun.j3d.utils.behaviors.sensor.SensorEvent.
From a brief look at the Android source code, it looks like there's simply no way to create your own SensorEvent object. This is a serious oversight on Google's part, if you ask me.
Edit: Here's what I do. I write a method named sensorChanged(Sensor sensor, float[] values) to do all the work, and just call it from the regular onSensorChanged() method. Then, when I want to test sensor handling from within my app, I call sensorChanged() with whatever values I want. I might not be able to create a SensorEvent object, but this way I can still test my code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With