GeoLocation App not working on Android Emulator

删除回忆录丶 提交于 2019-12-11 16:53:20

问题


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.



来源:https://stackoverflow.com/questions/29950660/geolocation-app-not-working-on-android-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!