gpt4 book ai didi

android - Geolocation Plugin.geoLocation 在模拟器或设备上没有给出答案

转载 作者:行者123 更新时间:2023-11-29 15:58:33 27 4
gpt4 key购买 nike

工作灯 6.2.0.00-20120814-0824

位置代码在浏览器模拟器中运行良好,但在 Android 模拟器中失败,成功或失败回调均未触发。

Logcat 显示:

10-06 16:00:40.707:W/PluginManager(3193):线程警告:对 WLGeolocationPlugin.getLocation 的 exec() 调用阻塞了主线程 75 毫秒。插件应该使用 CordovaInterface.getThreadPool()。

代码:

var showPosition = function(position) {
WL.Logger.debug("got a position");
var latitude = Number(position.coords.latitude).toFixed(2);
var longitude = Number(position.coords.longitude).toFixed(2);
$("#currentLocation").text(latitude + " / " + longitude);

};

var positionError = function(err) {
WL.Logger.debug("failed to get a position");
$("#status").text("position error" + err);

};

var geoPolicy = WL.Device.Geo.Profiles.RoughTracking(); // other profiles tried, same result

WL.Device.Geo.acquirePosition(showPosition, positionError, geoPolicy);

Android list 有

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>

在我添加那些之前我有不同的错误条件,表明权限错误,所以我认为权限现在是正确的。

--------编辑以添加更多信息----

我已经部署到真实的 Android 设备,但仍然没有触发任何回调。我确实在 LogCat 中看到了这些消息,表明 Worklight 正在使用 gps 做一些事情,但就我的代码而言没有提供答案

GC_FOR_ALLOC freed 738K, 11% free 10956K/12200K, paused 38ms, total 38ms
[ 10-07 15:30:21.656 13319:13340 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.onLocationChanged in WLLocationListener.java:174 :: The location has been updated!
[ 10-07 15:30:21.661 13319:13340 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 178 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
[ 10-07 15:30:21.661 13319:13340 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.onStatusChanged in WLLocationListener.java:156 :: The status of the provider gps has changed
[ 10-07 15:30:21.666 13319:13340 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.onStatusChanged in WLLocationListener.java:162 :: gps is TEMPORARILY_UNAVAILABLE
[ 10-07 15:30:21.686 546: 549 D/dalvikvm ]
GC_CONCURRENT freed 432K, 6% free 10266K/10920K, paused 1ms+1ms, total 15ms
[ 10-07 15:30:21.686 546:12382 D/dalvikvm ]
WAIT_FOR_CONCURRENT_GC blocked 9ms


[ 10-07 15:55:05.761 13671:13695 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.win in WLLocationListener.java:100 :: Acquired location age: 170 milliseconds. More than maximumAge of 100 milliseconds. Ignoring.
[ 10-07 15:55:05.791 13671:13695 D/dalvikvm ]
GC_FOR_ALLOC freed 530K, 9% free 10268K/11252K, paused 22ms, total 22ms
[ 10-07 15:55:05.791 13671:13695 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.onStatusChanged in WLLocationListener.java:156 :: The status of the provider gps has changed
[ 10-07 15:55:05.796 13671:13695 D/com.worklight.androidgap.plugin.WLLocationListener ]
WLLocationListener.onStatusChanged in WLLocationListener.java:162 :: gps is TEMPORARILY_UNAVAILABLE
[ 10-07 15:55:06.366 13671:13695 D/NONE ]
navigator :: back pages/home.html
[ 10-07 15:55:08.406 13671:13695 D/NONE ]
navigator :: loadPage :: myProfile
[ 10-07 15:55:08.431 13671:13695 D/NONE ]
myProfile :: buildDepartmentList Art and Architecture,Billing And Accounts,Claims
[ 10-07 15:55:08.441 13671:13695 D/NONE ]
myProfile :: myProfileInit fetch acquire pos
[ 10-07 15:55:21.741 365: 568 D/libgps ]
proxy_gps_status_cb: called. status(4)
[ 10-07 15:55:21.741 365: 568 D/libgps ]
proxy_gps_status_cb: normal GPS icon mode.
[ 10-07 15:55:21.746 365: 568 I/libgps ]
disarming wakeLockTimer
[ 10-07 15:55:21.746 365: 568 I/libgps ]
[proxy_gps_release_wakelock_cb][line = 653]: release_wakelock(0)

最佳答案

答案似乎是我需要指定一个 maximumAge 选项

  var geoPolicy = WL.Device.Geo.Profiles.RoughTracking(); // other profiles tried, same result

geoPolicy.maximumAge = 5000;

WL.Device.Geo.acquirePosition(showPosition, positionError, geoPolicy);

日志(如上所示)表明获得了一个答案,但根据其年龄将其丢弃。似乎我需要指定 maximumAge 大于获得职位所花费的时间。

关于android - Geolocation Plugin.geoLocation 在模拟器或设备上没有给出答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26220362/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com