androidlocationlocation-provider

Is possible to mock locations with Google's new fused location provider?


Is it possible to get applications such as FakeGPS to work with the new fused location provider (Google Play Services)?

I believe this is the issue:

09-20 17:18:41.842  21753-21809/? W/LocationManager﹕ java.lang.IllegalArgumentException: Incomplete location object, missing timestamp or accuracy? Location[gps 32.899542,-100.165065 acc=1 et=?!? alt=65.0]
        at android.location.LocationManager.setTestProviderLocation(LocationManager.java:1218)
        at com.lexa.fakegps.FakeGPSProvider.run(FakeGPSProvider.java:75)

Solution

  • The Fused Location Provider can only use mock locations provided by setMockMode() and setMockLocation(). Calling android.location.LocationManager.setTestProviderLocation() has no effect on the locations generated by Fused Location Provider.

    Although FakeGPS won't do anything for Fused Location Provider, the new Android training lesson for Mock Locations: Testing Using Mock Locations includes a sample app that injects mock locations into Fused Location Provider.