Why it happens
Because you want compass to point always in the north (or some other direction) independently of device rotation, it requires a continous read of magnetic sensor and a continous readraw of compass.
Using MapView
to force an overlay redraw you must use the invalidate()
mathod that requests the redraw of every overlay in the map, including the ovarlays that didn't change.
How to solve it
I've never used RoboGuice
so I can only advise on a standard solution.
You can't really stop the redrawing, if you want the compass to point in the right direction, neither you can can just draw one of the overlays (because you are drawing to a bitmap, that needs to be cleared and have every overlay redraw on it).
In my case, I used two tweaks to improve this:
- I set the sensor update frequency to the minimum frequency value.
- Before updating overlay I compare current direction with the one that was used to draw the compass. If they differ for a small number of degrees (like 3 degrees) I ignore the update and wait for an update with a bigger difference to request an overlay redraw.
Regards.