コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Forms.Init(this, savedInstanceState);

            SimpleLocationManager.SetContext(this);
            SimpleLocationManager.HowOftenShowUseLocationDialog        = SimpleLocationManager.ShowUseLocationDialog.Once;
            SimpleLocationManager.HandleLocationPermission             = true;
            SimpleLocationManager.ShouldShowRequestPermissionRationale = true;

            app = new App();
            BackgroundLocationService.App = app;

            app.startButton.Clicked += delegate {
                StartService(new Intent(this, typeof(BackgroundLocationService)));
            };
            app.stopButton.Clicked += delegate {
                StopService(new Intent(this, typeof(BackgroundLocationService)));
            };
            app.SimpleLocationManager.ShowRequestPermissionRationale += delegate {
                ShowRequestPermissionRationale();
            };

            LoadApplication(app);
        }
コード例 #2
0
        public App()
        {
            InitializeComponent();

            SimpleLocationManager = new SimpleLocationManager();
            var viewModel = new MainPageViewModel(SimpleLocationManager);

            MainPage = new MainPage(viewModel);
        }
コード例 #3
0
ファイル: App.cs プロジェクト: cumminsjp/SimpleLocation
        void InitSimpleLocationManager()
        {
            SimpleLocationManager = new SimpleLocationManager();
            SimpleLocationManager.LocationUpdatesStarted += () => infoLabel.Text = started;
            SimpleLocationManager.LocationUpdatesStopped += () => infoLabel.Text = stopped;
            SimpleLocationManager.LocationUpdated        += delegate {
                latitudeLabel.Text  = string.Format("Latitude: {0}", SimpleLocationManager.LastLocation.Latitude);
                longitudeLabel.Text = string.Format("Longitude: {0}", SimpleLocationManager.LastLocation.Longitude);
                directionLabel.Text = string.Format("Direction: {0} deg", SimpleLocationManager.LastLocation.Direction);
                speedLabel.Text     = string.Format("Speed: {0} m/s", SimpleLocationManager.LastLocation.Speed);

                Console.WriteLine(SimpleLocationManager.LastLocation);
            };
        }
コード例 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Forms.Init(this, savedInstanceState);
            FormsMaterial.Init(this, savedInstanceState);

            SimpleLocationManager.SetContext(this);
            SimpleLocationManager.HowOftenShowUseLocationDialog        = SimpleLocationManager.ShowUseLocationDialog.Once;
            SimpleLocationManager.HandleLocationPermission             = true;
            SimpleLocationManager.ShouldShowRequestPermissionRationale = true;

            app = new App();
            app.SimpleLocationManager.LocationUpdatesStarted         += () => StartService(new Intent(this, typeof(BackgroundLocationService)));
            app.SimpleLocationManager.LocationUpdatesStopped         += () => StopService(new Intent(this, typeof(BackgroundLocationService)));
            app.SimpleLocationManager.ShowRequestPermissionRationale += () => ShowRequestPermissionRationale();

            BackgroundLocationService.SimpleLocationManager = app.SimpleLocationManager;

            LoadApplication(app);
        }
コード例 #5
0
        public MainPageViewModel(SimpleLocationManager locationManager)
        {
            InitLocationManager(locationManager);

            ToggleButtonCommand = new Command(ToggleLocationUpdates);
        }