Example #1
0
        public override void OnDestroy()
        {
            // We need to shut things down.

            // Stop the handler.
            handler.RemoveCallbacks(runnable);

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

            notificationManager.Cancel(NOTIFICATION_ID);

            timestamper = null;
            isStarted   = false;
            base.OnDestroy();
        }
Example #2
0
        public override void OnCreate()
        {
            base.OnCreate();
            //Log.Info(TAG, "OnCreate: the service is initializing.");

            timestamper = new UtcTimestamper();
            handler     = new Handler();

            // This Action is only for demonstration purposes.
            runnable = new Action(() =>
            {
                if (timestamper != null)
                {
                    //Log.Debug(TAG, timestamper.GetFormattedTimestamp());
                    handler.PostDelayed(runnable, DELAY_BETWEEN_LOG_MESSAGES);
                }
            });
        }