GPS update rate for Android

I am writing a knee snapping application, but have run into a GPS update rate problem. At speeds above 75 km / h (21 m / s), my code stops working. My question is, how can I request updates at a faster rate? I need it to run at speeds of up to 300 km / h (83 m / s) and want the application to receive updates every couple of meters, which would mean that it would need to update every 0.025 seconds at 300 km / h. Below is my code, I tried an alternative code to get a timestamp, but got the same result, I believe that the GPS update rate problem is not a code problem. I wanted to update every couple of meters at 300 km / h if the phone passes through a radius of proximity along a tangent.

int prox = 30;      // Proximity Switch To Finish Line = 30 meters
int speedGov = 0;   // Speed In Kmh

public void OnProviderDisabled(string provider)
{
}

public void OnProviderEnabled(string provider)
{
}

public void OnStatusChanged(string provider, Availability status, Bundle extras)
{
}

protected override void OnResume()
{
    this.InitializeLocationManager();
    base.OnResume();
    _locationManager.RequestLocationUpdates(_locationProvider, 0, 0, this);
}

void InitializeLocationManager()
{
    _locationManager = (LocationManager)GetSystemService(LocationService);
    Criteria criteriaForLocationService = new Criteria
    {
        Accuracy = Accuracy.Fine
    };
    IList<string> acceptableLocationProviders =     _locationManager.GetProviders(criteriaForLocationService, true);
    if (acceptableLocationProviders.Any())
    {
        _locationProvider = acceptableLocationProviders.First();
    }
    else
    {
        _locationProvider = String.Empty;
    }
}

public void OnLocationChanged(Location location)
{
    _currentLocation = location;
    if (_currentLocation == null)
    {
    }
    else
    {
        d2fl = Convert.ToInt32(_currentLocation.DistanceTo(fl));
        speedGov = Convert.ToInt32(_currentLocation.Speed * 3.6);
    }
}

int A = 0;      // 1st Distance to Finish Line
int B = 1000000;    // 2nd Distance to Finish Line

// Get Time Stamp
while (true)
{
    A = d2fl;
    if (A > B && d2fl < prox && speedGov > 2)   // Travelling away from Finish Line & Within 30m proximity to Finish Line & Going faster than 2km/h
    {
        // Time stamp for when phone first starts travelling away from Finish Line
        string hours = DateTime.Now.ToString("HH");
        string minutes = DateTime.Now.ToString("mm");
        string seconds = DateTime.Now.ToString("ss");
        string milliseconds = DateTime.Now.ToString("fff");
        lapFinishTimeStamp = (Convert.ToDecimal(hours) * 3600) + (Convert.ToDecimal(minutes) * 60) + Convert.ToDecimal(seconds) + (Convert.ToDecimal(milliseconds) / 1000);
        A = 0;
        B = 1000000;
        break;
    }
    B = A;
}

// Alternate Get Time Stamp - worked the same as above "Get Time Stamp"
while (true)
{
    int A = d2fl;
    Thread.Sleep(5);
    int B = d2fl;
    if (A < B && d2fl < prox && speedGov > 2)
    {
        string hours = DateTime.Now.ToString("HH");
        string minutes = DateTime.Now.ToString("mm");
        string seconds = DateTime.Now.ToString("ss");
        string milliseconds = DateTime.Now.ToString("fff");
        lapFinishTimeStamp = (Convert.ToDecimal(hours) * 3600) +     (Convert.ToDecimal(minutes) * 60) + Convert.ToDecimal(seconds) + (Convert.ToDecimal(milliseconds) / 1000);
        A = 0;
        B = 0;
        break;
        }
    A = 0;
    B = 0;
}

, . Galaxy S4 .

GPS, , , GPS ( 1,6 ), , , , ?

+4
2

(1,1-1,6 ) , (1 ).

: GPS- ? , , , GPS (, - //). 10 20 , 100 50 , , 25 . , CPU GPS - , .

GPS, .

+2

gps 1hz, .
, , 10/, .
, , , GPS- , 1 2 .

. .

, 3-5 . , , migght addionally timeAccuracy. 5 100 / 0,18 . location.getHoricontalAccuracy() ( )

+2

Source: https://habr.com/ru/post/1598802/


All Articles