public override void OnCreate() { base.OnCreate(); #if DEBUG Android.Util.Log.Info(Tag, "OnCreate: the service is initializing."); #endif _stopHandler = new Handler(); _activityCommon = new ActivityCommon(this, null, BroadcastReceived); _activityCommon.SetLock(ActivityCommon.LockType.Cpu); if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { if (_activityCommon.NotificationManager != null) { Android.App.NotificationChannel notificationChannel = new Android.App.NotificationChannel( ServiceNotificationChannelId, Resources.GetString(Resource.String.app_name), Android.App.NotificationImportance.Low); _activityCommon.NotificationManager.CreateNotificationChannel(notificationChannel); } } lock (ActivityCommon.GlobalLockObject) { EdiabasThread ediabasThread = ActivityCommon.EdiabasThread; if (ediabasThread != null) { ediabasThread.ActiveContext = this; } } }
private Task CreateNotificationChannel() { 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(Task.CompletedTask); } var name = "TV_Shows_Notification_Channel"; var description = "Notification channel for showing new episodes notifications"; var channel = new Android.App.NotificationChannel(CHANNEL_ID, name, Android.App.NotificationImportance.Default) { Description = description }; var notificationManager = (Android.App.NotificationManager)Android.App.Service.NotificationService; notificationManager.CreateNotificationChannel(channel); return(Task.CompletedTask); }