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); } }
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); }
/// <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); } }
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); } }
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); } }