Paul
Paul

Reputation: 303

Mock Location in Android 4.2

I have an Android application that uses a mock GPS location provider to feed latitude/longitude coordinates into the Google Maps Navigation application. The application works fine with all pre-Android 4.2 devices, but will not work on a Nexus 10. I've done a bit of research today, but haven't been able to figure out what changed.
The problem appears to be that the LocationManager is not being updated with the new coordinates. The following lines from the logcat on a device running 4.1 (the first from the LocationManager, and second from my application):

01-29 13:40:22.501: I/LocationManagerService(770): handleLocationChanged for com.abc.navigationsimulator, Provider: gps, Lat: 42.2977542, Long: -88.00421718333334, Bearing: 278.9126, Accuracy: 30.0

01-29 13:40:22.611: V/Navigation Simulator(14875): lat: 42.2977542 lon: -88.00421718333334 bearing: -81.08741 speed: 10.610382 time: 1359488422459

I only see the second line on the 4.2 device.
Does anyone know what has changed? Thanks.

Upvotes: 2

Views: 1955

Answers (1)

leonman30
leonman30

Reputation: 264

It's the blasted elapsed real time nanos http://developer.android.com/reference/android/location/Location.html#getElapsedRealtimeNanos%28%29

New and improved JB 4.2 wants to use that for knowing how old the fix was. So set it using setElapsedRealtimeNanos with appropriate check that you are doing it on the right Android platform

Upvotes: 2

Related Questions