Example #1
0
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layouts.MainLayout);

            // Find UI controls
            txStatus = FindViewById<TextView>(R.Ids.txStatus);
            txProvider = FindViewById<TextView>(R.Ids.txProvider);
            txAccuracy = FindViewById<TextView>(R.Ids.txAccuracy);
            txLatitude = FindViewById<TextView>(R.Ids.txLatitude);
            txLongtitude = FindViewById<TextView>(R.Ids.txLongtitude);
            txAltitude = FindViewById<TextView>(R.Ids.txAltitude);
            txSpeed = FindViewById<TextView>(R.Ids.txSpeed);
            txExtra = FindViewById<TextView>(R.Ids.txExtra);

            // capitalize getSystemService
            service = (LocationManager)GetSystemService(LOCATION_SERVICE);

            enabled = service.IsProviderEnabled(LocationManager.GPS_PROVIDER);
            if (enabled)
            {
                txStatus.Text = "GPS enabled";
            }
            else
            {
                txStatus.Text = "GPS not enabled - change settings first and come back";
                return;
            }

            var criteria = new Criteria { Accuracy = Criteria.ACCURACY_FINE };
            provider = service.GetBestProvider(criteria, false);
            var location = service.GetLastKnownLocation(provider);
            if (null != location)
            {
                txProvider.Text = "Using provider '" + provider + "'";
                OnLocationChanged(location);
            }
            else
            {
                txProvider.Text = "No location";
            }
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layout.MainLayout);

            SetUpMapIfNeeded();

            service = (LocationManager)GetSystemService(LOCATION_SERVICE);
            enabled = service.IsProviderEnabled(LocationManager.GPS_PROVIDER);
            if (!enabled)
            {
                return;
            }

            var criteria = new Criteria { Accuracy = Criteria.ACCURACY_FINE };
            provider = service.GetBestProvider(criteria, false);
            var location = service.GetLastKnownLocation(provider);
            if (null != location)
            {
                OnLocationChanged(location);
            }


        }