Is it possible to activate the network location provider on the android emulator? Maybe with a fake cellid?
-
why do you need the network location provider? is that what you are looking for : http://osdir.com/ml/AndroidDevelopers/2009-03/msg02179.html – Sephy Mar 11 '10 at 12:07
-
1It would be nice to be able to test the network location provider on the emulator... The link is not what I'm looking for thanks. – Janusz Mar 11 '10 at 12:33
-
you mean, to see if the GPS is activated? – Sephy Mar 11 '10 at 14:32
-
4The network location provider can give you a location without activating the gps sensor. This saves battery and is faster then getting the gps location. Therefor I want to use it in my app. And therefor I would like to test it with the emulator – Janusz Mar 11 '10 at 16:06
-
@Janusz exactly. unless you need meter-scale accuracy, it is inappropriate to request GPS permission. not only does it save battery, it's faster to obtain a "fix" and is less invasive with regard to privacy. – Jeffrey Blattman Apr 18 '12 at 18:01
4 Answers
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.
"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)
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.

- 985
- 1
- 9
- 16
do you need to send location info to the emulator? if you wanna do this, yo can send location to the emulator throug the adb console and the geo command http://developer.android.com/guide/developing/tools/emulator.html#geo
i don't know if its possible to send fake cellid, but its possible with gps coordinates, if your application listen to any gps provider

- 7,385
- 3
- 27
- 22
-
4GPS works fine, but I'm using the Network Location Provider and it seems that this is not testable on the emulator. – Janusz Nov 25 '10 at 10:24
Perhaps you can install the UnifiedNlp network location provider in your emulator, then you at least have a NETWORK
location provider, even if it doesn't bring any data.
That provider is modular, so perhaps² you can write a backend for it to inject your mock locations.

- 1,378
- 19
- 33
go to your emulator Settings>Location Access and check "Wi-Fi & mobile network location"

- 1