在 Android 模拟器中激活网络位置提供程序?

Activating Network Location Provider in the Android Emulator?(在 Android 模拟器中激活网络位置提供程序?)
本文介绍了在 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 模拟器中激活网络位置提供程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)