public override void OnCreate() { base.OnCreate(); timestamper = new UtcTimestamper(); handler = new Handler(); runnable = new Action(() => { if (timestamper != null) { handler.PostDelayed(runnable, DELAY_BETWEEN_LOG_MESSAGES); } }); }
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, DelayBetweenLogMessages); } }); }
public override void OnDestroy() { // We need to shut things down. Log.Debug(_tag, GetFormattedTimestamp()); Log.Info(_tag, "OnDestroy: The started service is shutting down."); // Stop the handler. _handler.RemoveCallbacks(_runnable); // Remove the notification from the status bar. var notificationManager = (NotificationManager)GetSystemService(NotificationService); notificationManager.Cancel(NotificationId); _timeStamper = null; _isStarted = false; base.OnDestroy(); }
public override void OnCreate() { DispatchNotificationThatServiceIsRunning(); Log.Info(TAG, "OnCreate: the service is initializing."); base.OnCreate(); timestamper = new UtcTimestamper(); handler = new Handler(); // This Action is only for demonstration purposes. runnable = new Action(() => { if (timestamper != null) { UpdateNotification(timestamper.GetFormattedTimestamp()); Log.Debug(TAG, timestamper.GetFormattedTimestamp()); handler.PostDelayed(runnable, DELAY_BETWEEN_LOG_MESSAGES); } }); }