Android模拟器具有地理位置的问题 [英] Android Emulator having issues with Geolocation
问题描述
我一直使用Android和2.2模拟器现在有点刚开始运行到一个问题。我的地理位置未在模拟器被设置。起初我还以为是与PhoneGap的0.92一个问题,但恢复到0.91,并打开一个旧项目后也是如此。在DDMS我的坐标设置和我'发送'他们。我也telnet和发出地理fix命令,我得到一个OK的响应。似乎一切都很好,但由于某些原因模拟器仍然毫无头绪。
I have been using Android and the 2.2 emulator for a bit now and just started running into an issue. My geolocation is not being set in the Emulator. At first I thought it was an issue with PhoneGap 0.92 but after reverting to .91 and opening an older project the same holds true. In DDMS my coordinates are set and I 'send' them. I also telnet and issue the geo fix command and I get a OK response. It seems all is well but for some reason the emulator still has no clue.
我发现了一些旧帖子回复:设置时区。我这样做。仍然没有运气。我甚至使用浏览器,访问html5demos.com/geo~~V,看是否能找到我,没有。
I found some older posts re: setting the time zone. I did that. Still no luck. I even use the browser and go to html5demos.com/geo to see if it can find me and it does not.
这用来工作,不知道从那以后发生了什么。我更新了我的Java版本1.6.0.22的。 Android SDK中是2.2,API 8,修订2。
This used to work, not sure what happened since then. I updated my version of Java 1.6.0.22. Android SDK is 2.2, API 8, revision 2.
任何提示或技巧将AP preciated。我停留在这一点上。
Any tips or tricks would be appreciated. I am stuck at this point.
我的PhoneGap / JS调用:
My Phonegap/JS call:
var getLocation = function() {
var suc = function(p){
alert(p.coords.latitude + " " + p.coords.longitude);
};
var fail = function(error){
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
};
navigator.geolocation.getCurrentPosition(suc,fail);
}
在'失败'持续发生。错误code 2.最后的位置提供被禁用。
The 'fail' keeps happening. Error code 2. The last location provider was disabled.
- 更新
仍然有同样的问题。我发现我在夏天使用回旧的地图应用程序,它是2.1。于是我重新编译和运行上一个2.1模拟器,并且也不能正常工作。有趣的是在eclipse当我在DDMS和发送坐标2.1我'看',它已经在模拟器已发送但与2.2我不确认。
--UPDATE Still having the same issue. I found an older mapping application I used back in the summer, it was 2.1. So I recompiled and ran that on a 2.1 emulator and that is also not working. The funny thing is in eclipse when i am in DDMS and send coordinates to 2.1 I 'see' a confirmation that it has been sent in the emulator but with 2.2 I do not.
最大的区别是,我身后的代理,现在(新工作)在那里之前,我是不会。我想我可以尝试在家里......不知道有没有关系。
The big difference is I am behind a proxy now (new job) where before I was not. I guess I could try at home...not sure if that matters.
推荐答案
您必须把enableHighAccuracy到getCurrentPosition,例如:
You have to put enableHighAccuracy into getCurrentPosition, for example:
navigator.geolocation.getCurrentPosition(onSuccess, onError, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });
接下来,你必须远程登录到模拟器,和地缘收拾你想要的位置(经度,纬度):
Next, you have to telnet into the emulator, and geo fix the location(longitude, latitude) you want:
kelvin@locahost:~$ telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
geo fix 101.689453 3.074695
OK
quit
Connection closed by foreign host.
然后运行您的PhoneGap应用程序。
Then run your PhoneGap app.
这篇关于Android模拟器具有地理位置的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!