Can I Provide Coordinates to the Location Service?

283
2
01-22-2013 07:32 AM
JamesGist
New Contributor
I would like to spoof the location in my ap in order to demonstrate some functionality.  I would like to be able to provide coordinates to the location service in regular intervals in order to simulate moving along a path.

Is this possible?
0 Kudos
2 Replies
AndyGup
Esri Regular Contributor
James, yes if you have an app that already is using a Location Listener you can use what are called "Mock" locations. There are a few steps to follow:

1) Add this line to your manifest permissions:

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION">


2) Make sure in your phone settings that you have checked "Allow mock locations"
3) Create and inject the mock locations:

Location mockLocation = new Location(mocLocationProvider); 
mockLocation.setLatitude(-34.000);   
mockLocation.setLongitude(72.000); 
mockLocation.setAltitude(2000); 
mockLocation.setTime(1359043067); 
locationManager.setTestProviderLocation( mocLocationProvider, mockLocation); 


4) To simulate movement set up a handler.postDelayed(this,<delay in ms>) and loop through an array containing your mock locations.
0 Kudos
JamesGist
New Contributor
Thanks for the info Andy.  I'll give this a try in the next day or so and report back.
0 Kudos