Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get Fast (5 milliseconds) location updates in Android..?

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 ?

like image 677
Arsalan Avatar asked Feb 14 '23 07:02

Arsalan


1 Answers

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.

like image 63
Reto Meier Avatar answered May 04 '23 16:05

Reto Meier