webview中的地理位置错误
在 Android 2.2 模拟器上,使用以下脚本加载空白页面失败:
navigator.geolocation.getCurrentPosition(
function(pos){
var lat = pos.coords.latitude;
var lon= pos.coords.longitude;
alert('success ' + lat + ',' + lon);
},
function(){
alert('geoloc test FAILED');
}
);
具体来说,它会导致错误:
I/Database( 306): sqlite returned: error code = 14, msg = cannot open file at source line 25467
我已将我能找到的几乎所有与地理相关的权限添加到清单中:
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<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" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
我不确定我还能做什么做!我已经这样做了几个小时,但没有任何进展 - 任何见解将不胜感激。
(发送geo fix
后,我可以在模拟器浏览器中查看我的位置)
On an Android 2.2 emulator, loading a blank page with the following script fails:
navigator.geolocation.getCurrentPosition(
function(pos){
var lat = pos.coords.latitude;
var lon= pos.coords.longitude;
alert('success ' + lat + ',' + lon);
},
function(){
alert('geoloc test FAILED');
}
);
Specifically, it causes the error:
I/Database( 306): sqlite returned: error code = 14, msg = cannot open file at source line 25467
I've added pretty much every geo-related permission I can find to the manifest:
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<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" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
I'm not sure what else I can do! I've been at this for hours with no progress - any insight would be greatly appreciated.
(I am able to view my location in the emulator browser after sending geo fix
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 phonegap 邮件列表,此错误属于正常现象,可以安全地忽略。所有 Android 设备 2.X 及以上版本的浏览器中都内置了地理定位功能。
一个可能有用的注释:在测试地理定位时,使用 DDMS 设置一个假位置,或者简单地 telnet 到 localhost:5554 并运行命令
geo fix 50.0 50.0
,例如,将模拟 GPS 纬度/经度坐标设置为 (50, 50)。According to the phonegap mailing list, this error is normal and can be safely ignored. All Android devices 2.X onwards have geolocation built into the browser.
A possibly helpful note: when testing geolocation, it helped me a lot to use DDMS to set a fake location, or simply telnet to localhost:5554 and run the command
geo fix 50.0 50.0
, for example, to set mock gps lat/long coords to (50, 50).