如何在设备上模拟位置? [英] How to mock location on device?

查看:18
本文介绍了如何在设备上模拟位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在物理设备 (Nexus One) 上模拟我的位置?

How can I mock my location on a physical device (Nexus One)?

我知道您可以使用模拟器控制面板中的模拟器执行此操作,但这不适用于物理设备.

I know you can do this with the emulator in the Emulator Control panel, but this doesn't work for a physical device.

推荐答案

似乎唯一的办法就是使用模拟位置提供程序.

It seems the only way to do is to use a mock location provider.

您必须在设置中的开发面板中启用模拟位置并添加

You have to enable mock locations in the development panel in your settings and add

   <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> 

到您的清单.

现在您可以进入您的代码并创建您自己的模拟位置提供程序并设置此提供程序的位置.

Now you can go in your code and create your own mock location provider and set the location of this provider.

这篇关于如何在设备上模拟位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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