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;
int speedGov = 0;
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;
int B = 1000000;
while (true)
{
A = 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 = 1000000;
break;
}
B = A;
}
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 ), , , , ?