我在Android模拟器上遇到Worklight位置API问题。我正在使用IBM Worklight Studio 6.2.0.01-20141027-1531和Android模拟器操作系统级别4.4.2。
更新模拟器位置后,这些是我看到的日志:
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
我可以看到位置监听器捕获和更新我的UI的唯一方法是将maximumAge设置为高于29991929 - 例如299919290.我真的不明白这个29991929年龄来自哪里考虑我刚刚更新了位置。当然它应该是几毫秒而不是29991929 +
此外,如果我设置一个疯狂的大号,如299919290,我只获得第一个位置更新。在那之后,无论我多久更改一次位置,都不会选择这些更改:
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.
在我的实际设备上正常工作,但我需要在模拟器上运行。
答案 0 :(得分:2)
不幸的是,模拟器始终开始时间为午夜(这是known defect)。由于您似乎正在使用混合环境,因此您应该能够在Mobile Browser Simulator内进行测试 - 您可能希望在那里使用Scenario Widget,以便您以可重复的方式轻松测试不同的场景。或者,您可以尝试使用模拟位置或IBM Rational Test Workbench(阅读this answer了解更多信息)。