protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_location);
            startButton        = FindViewById <Button>(Resource.Id.btnStartLocationRequest);
            stopButton         = FindViewById <Button>(Resource.Id.btnStopLocationRequest);
            startButton.Click += StartButton_Click;
            stopButton.Click  += StopButton_Click;
            act     = this;
            lstView = FindViewById <ListView>(Resource.Id.lstLocations);

            fusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(this);
            settingsClient  = LocationServices.GetSettingsClient(this);
            locationRequest = new LocationRequest()
                              .SetPriority(LocationRequest.PriorityHighAccuracy)
                              .SetNumUpdates(10);
            locationRequest.SetFastestInterval(30000);
            locationRequest.SetInterval(30000);
            locationRequest.SetNeedAddress(true);
            locationRequest.SetLanguage("en");
            locationRequest.SetCountryCode("EN");
        }
Esempio n. 2
0
        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]);
        }