/// <summary> /// Обработчик остановки службы /// </summary> public override void OnDestroy() { // Остановка службы handler.RemoveCallbacks(runnable); notManager.Cancel(notServiceID); if (AndroidSupport.IsForegroundAvailable) { notManager.DeleteNotificationChannel(ProgramDescription.AssemblyMainName.ToLower()); } isStarted = false; // Освобождение ресурсов notBuilder.Dispose(); notManager.Dispose(); masterIntent.Dispose(); masterPendingIntent.Dispose(); // Глушение if (AndroidSupport.IsForegroundAvailable) { StopForeground(StopForegroundFlags.Remove); } else { StopForeground(true); } StopSelf(); foreach (BroadcastReceiver br in bcReceivers) { this.UnregisterReceiver(br); } // Стандартная обработка base.OnDestroy(); }