Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Friday, April 27, 2012
Activating Network Location Provider in the Android Emulator?
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.
"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.
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
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.
ReplyDelete"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.
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
ReplyDeletei don't know if its possible to send fake cellid, but its possible with gps coordinates, if your application listen to any gps provider