5

I'm using Fused Location Provider library in android. It is working perfectly fine. But I've an issue with it, it returns location updates in 5 sec minimum.

I've tried every thing like setting minimum updates time to 1 millisecond, and distance to 0.01 meter and Priority to PRIORITY_HIGH_ACCURACY

My code :

locationrequest.setInterval(1); // 1 milliseconds locationrequest.setSmallestDisplacement(0.01f); // 0.01 meters locationrequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

But no use, still minimum time between two successive location updates is 5 seconds.

My Questions is : Is there any way to decrease location updates time to 5 milliSeconds ?

-> I need location updates for only 10 minutes, So no issue with the high battery consumption.

-> I need any way (possible): Is there any external hardware available, which connects via Bluetooth and send location updates upto that level ?

Edits:

Let me ask you a different question : What can be the minimum possible time for location updates and how to achieve that ?

Let's say i want to track a car, which is moving with the speed of 400 KM/h, means 5 meter in about 50ms. So can you suggest any better way to track this car ?

Arsalan
  • 513
  • 1
  • 7
  • 22
  • That would consume a lot of battery though..is that ok? – Anirudha Dec 21 '13 at 08:34
  • @Anirudh Yes, No Problem with the battery consumption... Because the location updates are just required for **10 minutes**. – Arsalan Dec 21 '13 at 08:35
  • IMHO that is a stupid question that would eat the battery in a view hours, and also the GPS in a mobile is much too inaccurate. The absolute minimum range on my devices is about 3meters. A normal range is about 25-10metets. – rekire Dec 21 '13 at 08:36
  • 2
    The best resolution of GPS is typically about 5m. To make your request worthwhile the device would have to move that distance in 5ms. That's about 1000m/s, or three times the speed of sound. Are you sure you have this right? –  Dec 21 '13 at 08:38
  • @rekire As I mentioned above, I need location updates for only **10 minutes**. So, no issue with the battery consumption. – Arsalan Dec 21 '13 at 08:38
  • It's very unlikely that radios can provide updates that frequently. I'd bet you'd be lucky to see 1Hz, with consumer devices. – Michael Petrotta Dec 21 '13 at 08:38
  • Not a good idea. It'll drain the battery very quickly. – Vikram Gupta Dec 21 '13 at 08:38
  • have a look at [setFastestInterval](http://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html#setFastestInterval(long)) – Anirudha Dec 21 '13 at 08:43
  • @Anirudh Yes, I've tried but no success :( – Arsalan Dec 21 '13 at 08:44
  • 2
    200 position updates per second with precision less than a few metres? I'm afraid you will get nowhere near this from a phone. Even dedicated professional devices for high accuracy utilisation will not do that. given that civilian GPS cannot be more accurate than a few metres, you are asking for the impossible. – Simon Dec 21 '13 at 08:56
  • I'm guessing we're seeing an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) here - Arsalan is asking about his proposed solution to his problem, rather than describing the problem itself. Arsalan, it's been well described how you can't use the information you're asking for, even if it were available. Are you actually looking to smoothly animate a position fix on a map (which would require updates every 16ms)? Then look into [position interpolation](http://stackoverflow.com/questions/1739019). – Michael Petrotta Dec 21 '13 at 09:01
  • You asked if there is external hardware. The answer is no. Please do some reading about how GPS works. It is not possible for any device to get the kind of precision you are asking for. There are many reasons such as multipath reception (signals bouncing), atmospheric conditions which are not predictable and use of a single receiver frequency (at least for civilian use). You could augment the GPS location, perhaps with the accelerometer. As others have said, you should describe what you are trying to do rather than ask an impossible question of how to do it. – Simon Dec 21 '13 at 09:18
  • Thanks for every one for quick response. I've updated my question kindly review it again...! – Arsalan Dec 21 '13 at 09:47
  • 1
    Sorry, but you are still asking the wrong question. Maximum update rate will vary from phone to phone and specific manufacturer implementations. Without measuring it on any given device, this is another impossible question. However, you will not get more than 1 or 2 updates per second or probably about 3 to 5 metres if you use a position update listener. One more time - please describe WHAT you are trying to do. – Simon Dec 21 '13 at 09:52
  • @Simon : How to get 1/2 updates per second ? – Arsalan Dec 21 '13 at 10:12
  • @Simon : As i were unable to get update less than 5 seconds. – Arsalan Dec 21 '13 at 10:25
  • 1
    I have no idea about Fused, and it doesn't matter how often you **try** to get updates, you cannot get updates faster than the system can provide them. You will simply get the same location again. See http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long, float, android.location.Criteria, android.location.LocationListener, android.os.Looper). This is my last comment since you do not want to describe what you are trying to do. There is quite possibly a better way of doing this than using GPS for something it is not designed to do. – Simon Dec 21 '13 at 10:28
  • @Simon : Let's say i want to track a car, which is moving with the speed of 400 KM/h, means 5 meter in about 50ms. So can you suggest any better way to track this car ? – Arsalan Dec 27 '13 at 20:14
  • @MikeW : I've updated my question, Kindly review it again and suggest me accordingly. Thanks. – Arsalan Dec 27 '13 at 20:21
  • I think we've established that GPS in a mobile phone is not the way to go. Since you're apparently trying to track something faster than Formula 1 car I'd assume that money isn't much of an object, in which case Differential GPS with multiple sequenced receivers might give the result you need or a simple radio transponder would work for straight-line measurements with software interpreting for track layout. In either case you're way off topic for [so] so I'm now voting to close. –  Dec 27 '13 at 21:25
  • 1
    This question appears to be off-topic because it is about very specialised tracking hardware & software –  Dec 27 '13 at 21:26

1 Answers1

8

The precision and accuracy of location-sensing hardware (GPS, AGPS, etc.) means that getting updates more frequently than every few seconds isn't likely to provide meaningful results. In fact, technology like the Fused Location Provider is likely to prioritize getting more accurate results rather than providing results every few hundred milliseconds.

In addition to that, the battery drain from getting updates multiple times a second is likely to be very significant.

All that said. The way to get every update that your location-sensing hardware is receiving is to set the location update interval and minimum displacement to zero, and to prioritize accuracy.

locationrequest.setInterval(0); // No delay.
// locationrequest.setSmallestDisplacement(0); // This is the default.
locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

Note that this will give you every update, but depending on the hardware limitations, and potentially the Fused Location Provider implementation, there's no guarantee this will be any faster than the 5s frequency you've found so far.

Reto Meier
  • 96,655
  • 18
  • 100
  • 72
  • Thank you for your quick response... I've updated my question, Kindly review it again and suggest me any better way for tracking ? – Arsalan Dec 27 '13 at 20:19
  • 1
    If you're traveling in a straight line (drag car?) you can try and utilize the accelerometer (tracking speed with an accelerometer would be a new question). If it's a track, you'll need specialist hardware -- most likely physical sensors on the track that detect when your car passes them and a transponder in the car to identify it. – Reto Meier Dec 28 '13 at 17:22