1

I made a simple location service using Fused location, i test with a real device and with Genymotion's android virtual device.

The iterval for getting the locations are 5 seconds.

On a real device it is works nicely, the interval is almost exactly 5 seconds, check log: (onLC is for OnLocationChanged)

 03-17 11:59:27.115: I/Locationing_GpsService_Test(27147): onLC:Now!
 03-17 11:59:32.189: I/Locationing_GpsService_Test(27147): onLC:Now!
 03-17 11:59:37.259: I/Locationing_GpsService_Test(27147): onLC:Now!
 03-17 11:59:42.171: I/Locationing_GpsService_Test(27147): onLC:Now!
 03-17 11:59:47.215: I/Locationing_GpsService_Test(27147): onLC:Now!
 03-17 11:59:52.240: I/Locationing_GpsService_Test(27147): onLC:Now!

On Genymotions virtual device the interval is like 1 second:

03-17 12:10:20.280: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:21.270: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:22.269: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:23.271: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:24.273: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:25.273: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:26.275: I/Locationing_GpsService_Test(2616): onLC:Now!
03-17 12:10:27.273: I/Locationing_GpsService_Test(2616): onLC:Now!

Code for initalizing location requests:

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(5000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

Can anybody help me whats happening here?

Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222

3 Answers3

1

You expect that Fused location will work on emulator? Fused location is all about fusing mobile/wifi/gps signals - do you expect Genymotion mocks mobile/wifi/gps so that it inputs some meaningful data to Fused location? I don't think so.

Anyway if you look at setInterval you'll see:

You may also receive them faster than requested (if other applications are requesting location at a faster interval).

So setting mLocationRequest.setInterval(5000); actually doesn't mean anything.

Marian Paździoch
  • 8,813
  • 10
  • 58
  • 103
  • What do you mean by "You expect that Fused location will work on emulator?" It is an emulator, it should at least emulate. I do get locations, i can also tap on a small map to choose the locations for testing, the question was not about this. – Adam Varhegyi Mar 17 '15 at 11:33
1

Simply adding mLocationRequest.setFastestInterval(5000);did the trick, now Genymotion's Virtual Device also requesting location updates in a 5 seconds interval.

Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
1

The Genymotion gets location info immediately, and pass it to your app, so it don't need to wait, like on real device. It doesn't emulate (or simulate) process of finding GPS satellites, like in real GPS sensor, and also, it using your PC internet speed, instead of a mobile GPRS or public Wi-Fi, so it also gets your location from it almost immediately. The same do an ADB emulator. You should using real device for testing location services.

VadymVL
  • 5,366
  • 3
  • 26
  • 41