I would retrieve the values once on start, and subscribe for updates. 
Cache the latest value and pass it to js either when it changes or when the 2 
seconds is about to expire. 


> On May 14, 2015, at 9:46 AM, Alexander Sorokin (Akvelon) 
> <v-als...@microsoft.com> wrote:
> 
> Hi, community.
> 
> I am investigating device-motion plugin test failures on Android and I've 
> found that if the device (or emulator) is still, no SensorChanged events is 
> being raised. So the plugin adds accelerometer listener, waits for two 
> seconds (no updates), removes accelerometer listener and then calls fail 
> callback.
> 
> I've come up with three different approaches to solve this problem:
> 
> 1. We can pend the tests for Android.
> 2. We can save latest accelerometer value and pass it if no SensorChanged 
> events is fired in 2 secs. But this value can be outdated.
> 3. We can poll accelerometer continuously and don't add/remove listener. But 
> I believe that this approach can drain device battery.
> 
> What do you think, guys? Which way is best for us?
> 
> Thanks,
> Alexander Sorokin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
> For additional commands, e-mail: dev-h...@cordova.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to