UPDATED:
I managed to solve the specific problem that I encountered by introducing a static counter of class-scope and simply ignoring ever x number of events. But I still would like to know what I'm doing wrong: register the listener with a hint in microseconds instead of using one of the four given constants.
The activity in my application is related to sensors in order to get the orientation of the device, determine the roll and use it.
I use
SensorManager.registerListener(SensorEventListener listener, Sensor sensor, int rate)
to register my sensors. From the Android documentation for this method:
Parameters
[...]
rate
Speed ββsensor events are transmitted to. This is just a hint of the system. Events can be received faster or slower than the specified rate. Events usually get faster. The value must be one of SENSOR_DELAY_NORMAL, SENSOR_DELAY_UI, SENSOR_DELAY_GAME or SENSOR_DELAY_FASTEST or the desired delay between events in microseconds.
If I use one of 4 predefined constants, the application works fine; however, these constants all give speed hints that are too fast for my needs. I have to send a UDP packet containing some information every time the event changes, and the receiving party seems to be completely filled with messages using any of the predefined rates. Using an integer such as 30000 (because the API sets the values ββin microseconds), the application stops reporting sensor events together.
What am I missing, what prevents me from using my own event hints?
source share