在 Android 模拟器中激活网络位置提供程序? [英] Activating Network Location Provider in the Android Emulator?

查看:26
本文介绍了在 Android 模拟器中激活网络位置提供程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在android模拟器上激活网络位置提供程序?也许是用假细胞?

Is it possible to activate the network location provider on the android emulator? Maybe with a fake cellid?

推荐答案

相信你想要达到的,目前是不可能的.您不能将模拟位置数据放入模拟器的网络位置提供程序.

I believe that what you want to achieve is not possible at the moment. You cannot put mock location data to the emulator's network location provider.

提供模拟位置数据是作为 GPS 位置数据注入的,因此您必须从 GPS_PROVIDER 请求位置更新才能使模拟位置数据起作用."(引自Android,文档,提供模拟位置数据)

"Providing mock location data is injected as GPS location data, so you must request location updates from GPS_PROVIDER in order for mock location data to work." (Quote from Android, Documentation, Providing Mock Location Data)

我能想到的最接近的方法是从 位置管理器

The closest thing I can come up with would be to to create a "Test Provider" from the Location Manager

public void addTestProvider (String name, boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy)

并相应地设置参数 requiresNetworkrequiresCellrequiresSatellite.然后您可以将虚假位置发送给该提供商:

and set the arguments requiresNetwork, requiresCell and requiresSatellite accordingly. Then you can from put fake locations to that provider:

public void setTestProviderLocation (String provider, Location loc)

这接近但不完全符合您的要求.

That's close to but not exactly what you asked for.

这篇关于在 Android 模拟器中激活网络位置提供程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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