0

I'm having issues with the Worklight location API on Android emulator. I am using IBM Worklight Studio 6.2.0.01-20141027-1531 and Android emulator os level 4.4.2.

After updating the emulator location, these are the logs that I'm seeing:

W/PluginManager( 3350): THREAD WARNING: exec() call to WLGeolocationPlugin.getLocation blocked the main thread for 57ms. Plugin should use CordovaInterface.getThreadPool().
D/com.worklight.androidgap.plugin.WLLocationListener( 3350): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3350): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 29991929 milliseconds. More than maximumAge of 10000 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3350): WLLocationListener.onStatusChanged in WLLocationListener.java:156 :: The status of the provider gps has changed
D/com.worklight.androidgap.plugin.WLLocationListener( 3350): WLLocationListener.onStatusChanged in WLLocationListener.java:162 :: gps is TEMPORARILY_UNAVAILABLE

The only way I can see the location listener catching and updating my UI is by setting the maximumAge higher than 29991929 - for example 299919290. I don't really understand where this 29991929 age comes from considering I just updated the location. Surely it should be a few milliseconds rather than 29991929+

Also if I set a crazy large number such as 299919290, I only get the first location update. After that, no matter how often I change the location, those changes are not picked up:

D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30321246 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30320408 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30319563 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30318722 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30317902 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30317066 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
D/com.worklight.androidgap.plugin.WLLocationListener( 3452): WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 30316258 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.

Works fine on my actual device, however I need to get this working on the emulator.

4

1 回答 1

2

不幸的是,模拟器总是一开始就把时间定为午夜(这是一个已知的缺陷)。由于您使用的是混合环境,因此您应该能够在移动浏览器模拟器中进行测试——您可能希望在那里使用场景小部件,以便您以可重复的方式轻松测试不同的场景。或者,您可以尝试使用模拟位置或 IBM Rational Test Workbench(阅读此答案了解更多信息)。

于 2014-11-17T10:35:28.850 回答