在Android模拟器激活网络位置提供者?提供者、模拟器、位置、网络

2023-09-05 05:24:59 作者:清风与你醉

是否有可能激活的Andr​​oid模拟器的网络位置提供商?也许用假CELLID?

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位置更新。 (从的Andr​​oid,文档,提供模拟位置数据)

"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)

我可以拿出最接近的将是创建一个从测试提供商Location经理

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)

和设置参数的 requiresNetwork requiresCell 和 requiresSatellite 相应。然后你可以从把假的位置给供应商:

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.