public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
        {
            if (intent.Action.Equals(Constants.ACTION_START_SERVICE))
            {
                if (!isStarted)
                {
                    RegisterForegroundService();
                    handler.PostDelayed(runnable, Constants.DELAY_BETWEEN_LOG_MESSAGES);
                    isStarted = true;
                }
            }
            else if (intent.Action.Equals(Constants.ACTION_STOP_SERVICE))
            {
                Log.Info(TAG, "OnStartCommand: The service is stopping.");
                timestamper = null;
                StopForeground(true);
                StopSelf();
                isStarted = false;
                this.OnDestroy();
            }
            else if (intent.Action.Equals(Constants.ACTION_RESTART_TIMER))
            {
                Log.Info(TAG, "OnStartCommand: Restarting the timer.");
                timestamper.Restart();
            }

            return(StartCommandResult.StickyCompatibility);
        }
        public override void OnCreate()
        {
            base.OnCreate();
            locationManager = (LocationManager)GetSystemService(LocationService);
            timestamper     = new UtcTimestamper();
            handler         = new Handler();
            runnable        = () =>
            {
                if (timestamper == null)
                {
                    Log.Wtf(TAG, "Why isn't there a Timestamper initialized?");
                }
                else
                {
                    string msg = timestamper.GetFormattedTimestamp();
                    Log.Debug(TAG, msg);
                    //UpdateNotification();
                    Intent i = new Intent(Constants.NOTIFICATION_BROADCAST_ACTION);
                    i.PutExtra(Constants.BROADCAST_MESSAGE_KEY, msg);
                    Android.Support.V4.Content.LocalBroadcastManager.GetInstance(this).SendBroadcast(i);

                    //if (timestamper.ShouldGetLocation())
                    //{
                    //    //LocationRequest mLocationRequest = new LocationRequest();
                    //    //mLocationRequest.SetInterval(10000);
                    //    //mLocationRequest.SetFastestInterval(5000);
                    //    //mLocationRequest.SetPriority(LocationRequest.PriorityHighAccuracy);
                    //    Location location = mLocationRequest.
                    //}

                    handler.PostDelayed(runnable, Constants.DELAY_BETWEEN_LOG_MESSAGES);
                }
            };
        }
        public override void OnDestroy()
        {
            Binder = null;
            // Stop the handler.
            handler.RemoveCallbacks(runnable);

            // Remove the notification from the status bar.
            var notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Cancel(Constants.SERVICE_RUNNING_NOTIFICATION_ID);

            timestamper = null;
            isStarted   = false;

            base.OnDestroy();
        }