【问题标题】:GeoLocation App not working on Android Emulator地理定位应用程序无法在 Android 模拟器上运行
【发布时间】:2015-04-29 17:33:17
【问题描述】:

我正在使用在 Android Studio 中创建的模拟器测试地理位置应用程序。我已经使用似乎有效的 DDMS 通过了纬度和经度。我通过去谷歌并检查位置确认了这一点。位置会根据 Lat/Long 上的任何变化而变化。 但是,被测应用没有获取任何位置信息。该应用程序显示位置服务未打开,而实际上它已打开并且工作正常。是否有可以针对模拟器上的应用程序的特定命令?我也尝试过 Geo fix 命令,但遇到了同样的问题。

【问题讨论】:

    标签: android testing android-emulator geolocation functional-testing


    【解决方案1】:

    这对我有用一次。最好是使用实际设备,因为不能保证它每次都能正常工作。

    Android 2.x 模拟器不会返回地理定位结果,除非 enableHighAccuracy 选项设置为 true。

    在你的代码中也使用这个

     navigator.geolocation.getCurrentPosition(onSuccess, onError, 
    {
     maximumAge: 2000, timeout: 10000, enableHighAccuracy: true 
    });
    

    在模拟器中使用telnet输入固定坐标

    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.
    

    你可以阅读更多关于it here的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-24
      • 1970-01-01
      相关资源
      最近更新 更多