I am testing a Geo-location App using an Emulator created in Android Studio. I have passed the latitude and longitude using DDMS which seems to work. I confirmed it by going to Google and checking the location. The location changes based on any changes on the Lat/Long. However, the App under test is not getting any location information. The App displays that the location services is not turned on when in fact it is turned on and working fine. Is there a specific command that can target the App on the emulator? I also have tried Geo fix commands but experiencing the same issue.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
this worked for me once. Best is to use actual device as there is no guarantee that it will work everytime.
The Android 2.x simulators will not return a geolocation result unless the enableHighAccuracy option is set to true.
Also use this in your code
navigator.geolocation.getCurrentPosition(onSuccess, onError,
{
maximumAge: 2000, timeout: 10000, enableHighAccuracy: true
});
and use telnet in emulator to enter fixed co-ordinates
samvid@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 39.09091 27.44011
OK
quit
Connection closed by foreign host.
You can read more about it here.