为什么模拟位置会跳回真实位置 [英] Why is mock location jumping back to real position

查看:232
本文介绍了为什么模拟位置会跳回真实位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 LocationManager.GPS_PROVIDER 作为提供者名称(如此处所述)添加了测试提供者

I added a test provider using LocationManager.GPS_PROVIDER as provider name like described here

https://mobiarch.wordpress.com/2012/07/17/testing-with-mock-location-data-in-android/

在Google Maps应用中,我看到位置在模拟位置和真实位置之间跳跃,然后又回到模拟位置.

In Google Maps app, I see location jumping between mocked location and real location, and then back to mocked location.

为什么要跳到真实位置,我该如何阻止它?

Why is jumping to real location and how can I stop it?

也许我误解了如何使用模拟位置.我尚未找到任何官方文档.

Maybe I misunderstand how to use mock locations. I haven't found any official documentation available.

推荐答案

您很可能已配置了位置设置,以便手机(和应用程序)既可以使用GPS传感器的位置,也可以使用单元格的位置和wi-fi.自融合位置提供程序问世以来,系统获取您的位置的方式变得更加模糊.

You most likely have your location settings configured in a way that your phone (and apps) can use both the location from the GPS sensor and the location from the cells and wi-fi. Since the coming of the Fused Location Provider, the way the system fetches your location got a bit murkier.

模拟位置时,您只能模拟GPS传感器读数(当您通过模拟器设置模拟位置时也是如此).因此,当系统从GPS传感器向Google Maps提供位置信息时,它会给它一个假的,而从其他传感器提供位置时它将是真实的.

When you mock the position you are only able to mock the GPS sensor readings (this is also true for when you mock the position through the simulator settings). So when the system feeds Google Maps with a position from the GPS sensor it gives it the fake one, and when it provides the position from other sensors it will be the real one.

要测试我的说法是正确的,您可以将位置设置切换为仅限设备",并且您只应获得假的位置.

To test that I'm correct, you can switch location settings to "Device only" and you should only get the fake positions.

不幸的是,无法模拟其他传感器的读数.

Unfortunately there's no way to mock the other sensors readings.

这篇关于为什么模拟位置会跳回真实位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆