private LocationRequest CreateLocationRequest(long waitTime) { var locationRequest = new LocationRequest(); locationRequest.SetMaxWaitTime(waitTime); locationRequest.SetInterval(1000); locationRequest.SetFastestInterval(1000); locationRequest.SetPriority(LocationRequest.PriorityHighAccuracy); return(locationRequest); }
public async Task ChangeInterval(int miliseconds = 1000 * 60 * 30) { if (_locationRequest != null && _fusedLocationProviderClient != null) { _locationRequest.SetFastestInterval(miliseconds); _locationRequest.SetInterval(miliseconds); _locationRequest.SetMaxWaitTime(miliseconds + 10000); await RequestLocationUpdates(); } }
/** * Sets up the location request. Android has two location request settings: * {@code ACCESS_COARSE_LOCATION} and {@code ACCESS_FINE_LOCATION}. These settings control * the accuracy of the current location. This sample uses ACCESS_FINE_LOCATION, as defined in * the AndroidManifest.xml. * <p/> * When the ACCESS_FINE_LOCATION setting is specified, combined with a fast update * interval (5 seconds), the Fused Location Provider API returns location updates that are * accurate to within a few feet. * <p/> * These settings are appropriate for mapping applications that show real-time location * updates. */ void CreateLocationRequest() { mLocationRequest = new LocationRequest(); // Sets the desired interval for active location updates. This interval is // inexact. You may not receive updates at all if no location sources are available, or // you may receive them slower than requested. You may also receive updates faster than // requested if other applications are requesting location at a faster interval. // Note: apps running on "O" devices (regardless of targetSdkVersion) may receive updates // less frequently than this interval when the app is no longer in the foreground. mLocationRequest.SetInterval(UpdateInterval); // Sets the fastest rate for active location updates. This interval is exact, and your // application will never receive updates faster than this value. mLocationRequest.SetFastestInterval(FastestUpdateInterval); mLocationRequest.SetPriority(LocationRequest.PriorityHighAccuracy); // Sets the maximum time when batched location updates are delivered. Updates may be // delivered sooner than this interval. mLocationRequest.SetMaxWaitTime(MaxWaitTime); }
private void SetLocationRequest(LocationRequest request) { TableLayout table = FindViewById <TableLayout>(Resource.Id.callback_table_layout_show); Dictionary <string, string> paramList = new Dictionary <string, string>(); TableRow[] rows = new TableRow[table.ChildCount]; for (int i = 0; i < rows.Length; i++) { rows[i] = (TableRow)table.GetChildAt(i); paramList[((TextView)rows[i].GetChildAt(0)).Text] = ((EditText)rows[i].GetChildAt(1)).Text; } request.SetPriority(int.Parse(paramList[LocationRequestConstants.Priority])); request.SetInterval(long.Parse(paramList[LocationRequestConstants.Interval])); request.SetFastestInterval(long.Parse(paramList[LocationRequestConstants.FastestInterval])); request.SetExpirationTime(long.Parse(paramList[LocationRequestConstants.ExpirationTime])); request.SetExpirationDuration(long.Parse(paramList[LocationRequestConstants.ExpirationDuration])); request.SetNumUpdates(int.Parse(paramList[LocationRequestConstants.NumUpdates])); request.SetSmallestDisplacement(float.Parse(paramList[LocationRequestConstants.SmallestDisplacement])); request.SetMaxWaitTime(long.Parse(paramList[LocationRequestConstants.MaxWaitTime])); request.SetNeedAddress(bool.Parse(paramList[LocationRequestConstants.NeedAddress])); request.SetLanguage(paramList[LocationRequestConstants.Language]); request.SetCountryCode(paramList[LocationRequestConstants.CountryCode]); }