Beispiel #1
0
        protected override void OnTaskStateChanged(TaskState taskState)
        {
            if (taskState.Action.IsRemoveAction)
            {
                return;
            }
            Notification notification = null;

            byte[] bytes = new byte[taskState.Action.Data.Count];
            taskState.Action.Data.CopyTo(bytes, 0);

            if (taskState.State == TaskState.StateCompleted)
            {
                notification =
                    DownloadNotificationUtil.BuildDownloadCompletedNotification(
                        /* context= */ this,
                        Resource.Drawable.exo_controls_play,
                        CHANNEL_ID,
                        /* contentIntent= */ null,
                        Utils.FromUtf8Bytes(bytes));
            }
            else if (taskState.State == TaskState.StateFailed)
            {
                notification =
                    DownloadNotificationUtil.BuildDownloadFailedNotification(
                        /* context= */ this,
                        Resource.Drawable.exo_controls_play,
                        CHANNEL_ID,
                        /* contentIntent= */ null,
                        Utils.FromUtf8Bytes(bytes));
            }
            int notificationId = FOREGROUND_NOTIFICATION_ID + 1 + taskState.TaskId;

            NotificationUtil.SetNotification(this, notificationId, notification);
        }