Exemplo n.º 1
0
        public override void OnStart(Intent intent, int startId)
        {
            try {
                var action        = intent.Action;
                var widgetManager = ServiceContainer.Resolve <WidgetSyncManager>();

                if (action == WidgetProvider.StartStopAction)
                {
                    widgetManager.StartStopTimeEntry();
                }
                else if (action == WidgetProvider.ContiueAction)
                {
                    // Get entry Id string.
                    var  entryId = intent.GetStringExtra(WidgetProvider.EntryIdParameter);
                    Guid entryGuid;
                    Guid.TryParse(entryId, out entryGuid);

                    // Set correct Guid.
                    var widgetUpdateService = ServiceContainer.Resolve <IWidgetUpdateService> ();
                    widgetUpdateService.EntryIdStarted = entryGuid;

                    widgetManager.ContinueTimeEntry();
                }
            } finally {
                WakefulBroadcastReceiver.CompleteWakefulIntent(intent);
                StopSelf(startId);
            }
        }
Exemplo n.º 2
0
        /// <Docs>The Context in which the receiver is running.</Docs>
        /// <summary>
        /// This method is called when the BroadcastReceiver is receiving an Intent
        ///  broadcast.
        /// </summary>
        /// <param name="context">Context object.</param>
        /// <param name="intent">Intent object.</param>
        public override void OnReceive(Context context, Intent intent)
        {
            System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, "Region State Change Received"));
            var serviceIntent = new Intent(context, typeof(GeofenceTransitionsIntentService));

            serviceIntent.AddFlags(ActivityFlags.IncludeStoppedPackages);
            serviceIntent.ReplaceExtras(intent.Extras);
            serviceIntent.SetAction(intent.Action);
            WakefulBroadcastReceiver.StartWakefulService(context, serviceIntent);

            this.ResultCode = Result.Ok;
        }
Exemplo n.º 3
0
        protected override async void OnHandleIntent(Intent intent)
        {
            var notificationBuilder = GetNotificationCompatBuilder(); Mvx.Resolve <DroidNotificationCompatBuilder <TNotificationData> >();
            var notificationManager = (NotificationManager)ApplicationContext.GetSystemService(NotificationService);

            foreach (var notificationData in await GetNotificationsData())
            {
                var notificationToShow = notificationBuilder.BuildNotification(ApplicationContext, notificationData);
                notificationManager.Notify(Interlocked.Increment(ref notificationId), notificationToShow);
            }

            WakefulBroadcastReceiver.CompleteWakefulIntent(intent);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Handles a given Intent <see cref="IntentService.OnHandleIntent(Intent)"/>
 /// </summary>
 /// <param name="intent">the Intent to handle</param>
 protected override void OnHandleIntent(Intent intent)
 {
     // onHandleIntent, started handling a notification event
     try
     {
         String action = intent.Action;
         if (ACTION_START.Equals(action))
         {
             processStartNotification(intent.Extras);
         }
     }
     finally
     {
         WakefulBroadcastReceiver.CompleteWakefulIntent(intent);
     }
 }
Exemplo n.º 5
0
        protected override void OnHandleIntent(Intent intent)
        {
            try
            {
                LogHelper.Debug($"START { DateTime.Now }");

                // メール受信
                MimeMessage message;
                string      messageUid;
                messageUid = GetMessage(lastMessageUid, out message);

                Bundle bundleMessage = null;
                if (messageUid != null)
                {
                    try
                    {
                        if (messageUid == lastMessageUid)
                        {
                            // 前回メッセージのUIDが一致した場合は前回のBundleを参照
                            bundleMessage = lastBundleMessage;
                        }
                        else
                        {
                            bundleMessage = CreateBundleMessage(messageUid, message);
                        }

                        ((MainApplication)Application).OnReceiveMail(bundleMessage);

                        lastMessageUid    = messageUid;
                        lastBundleMessage = bundleMessage;
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error(ex);
                    }
                }
            }
            finally
            {
                WakefulBroadcastReceiver.CompleteWakefulIntent(intent);
            }
        }
Exemplo n.º 6
0
 protected override void OnHandleIntent(Intent intent)
 {
     try
     {
         lock (this)
         {
             var instanceID = InstanceID.GetInstance(this);
             //instanceID.DeleteInstanceID();
             var _deviceToken = instanceID.GetToken(PushNotificationCredentials.GoogleApiSenderId, GoogleCloudMessaging.InstanceIdScope, null);
             Settings.Current.DeviceToken   = _deviceToken;
             Settings.Current.AttemptedPush = true;
         }
         if (intent.Extras != null)
         {
             //Only do this when the service is started from a WakefulBroadcastReceiver
             WakefulBroadcastReceiver.CompleteWakefulIntent(intent);
         }
     }
     catch (Exception ex)
     {
         Log.Info(AppConstants.TAG, ex.Message);
     }
 }