Пример #1
0
        private void NotiServiceCreat()
        {
            if (Build.VERSION.SdkInt < BuildVersionCodes.O)
            {
                // Notification channels are new in API 26 (and not a part of the
                // support library). There is no need to create a notification
                // channel on older versions of Android.
                return;
            }

            var name        = "Name";
            var description = "description";
            var channel     = new Android.App.NotificationChannel(CHANNEL_ID, name, Android.App.NotificationImportance.Default)
            {
                Description = description
            };
            var notificationManager = (Android.App.NotificationManager)GetSystemService(NotificationService);

            notificationManager.CreateNotificationChannel(channel);
        }
        void CreateNotificationChannel()
        {
            var alarmAttributes = new Android.Media.AudioAttributes.Builder()
                                  .SetContentType(Android.Media.AudioContentType.Unknown)
                                  .SetUsage(Android.Media.AudioUsageKind.NotificationRingtone).Build();

            if (Build.VERSION.SdkInt < BuildVersionCodes.O)
            {
                return;
            }

            var name                   = "BitChute";
            var description            = "BitChute for Android";
            var nameBackgroundPlayback = "BitChute Background Streaming";
            var channelSilent          = new Android.App.NotificationChannel(CHANNEL_ID, name + " Silent", Android.App.NotificationImportance.High)
            {
                Description = description
            };

            var channel = new Android.App.NotificationChannel(CHANNEL_ID + 1, name, Android.App.NotificationImportance.High)
            {
                Description = description
            };

            var backChannel = new Android.App.NotificationChannel(BACKGROUND_CHANNEL_ID, nameBackgroundPlayback, Android.App.NotificationImportance.Max)
            {
                Description          = description,
                Importance           = NotificationImportance.Max,
                LockscreenVisibility = NotificationVisibility.Public
            };

            channel.LockscreenVisibility = NotificationVisibility.Public;
            var notificationManager = (Android.App.NotificationManager)GetSystemService(NotificationService);

            channelSilent.SetSound(null, null);
            backChannel.SetSound(null, null);
            notificationManager.CreateNotificationChannel(channel);
            notificationManager.CreateNotificationChannel(channelSilent);
            notificationManager.CreateNotificationChannel(backChannel);
        }