Beispiel #1
0
 private void WeatherServiceStop(ServiceApi api)
 {
     if (!api.ExistsAppWidget(this))
     {
         api.StopService(this, new Intent(this, typeof(WeatherService)));
     }
 }
        private void OnTimerTick(object state)
        {
            if (IfCancellationRequested() || _timer == null)
            {
                return;
            }

            try
            {
                _log.DebugFormat("Scheduler (Count = '{0}').", _count);

                var api = new ServiceApi();
                api.ArrangeAppWidgetSettings(this);

                if (IfCancellationRequested())
                {
                    return;
                }

                if (!api.ExistsAppWidget(this))
                {
                    StopSelf();
                    return;
                }

                api.AppWidgetUpdateService(this, null);

                if (IfCancellationRequested())
                {
                    return;
                }

                var isBootCompletedReceiver = AppSettings.Default.IsBootCompletedReceiver;
                if (isBootCompletedReceiver)
                {
                    AppSettings.Default.IsBootCompletedReceiver = false;
                }

                api.AppWidgetWeatherDataUpdateService(this, isBootCompletedReceiver, _cancellationTokenSource.Token);
            }
            catch (System.OperationCanceledException ex)
            {
                _log.Debug(ex);
            }
            catch (Exception ex)
            {
                _log.Error(ex);
            }
            finally
            {
                if (_count + 1 == uint.MaxValue)
                {
                    _count = 0;
                }
                _count++;
            }
        }
Beispiel #3
0
        private void WeatherServiceStart(ServiceApi api)
        {
            var serviceType = typeof(WeatherService);

            if (api.ExistsAppWidget(this) && !WeatherService.IsServiceRunning)
            {
                api.StartService(this, new Intent(this, serviceType));
            }
        }