Exemplo n.º 1
0
        protected virtual Bitmap DrawableBitmap(object obj)
        {
            try
            {
                string text = obj.ToString();

                bmp        = BitmapFactory.DecodeResource(context.Resources, canvasResourceMaterial);
                mutableBmp = bmp.Copy(Bitmap.Config.Argb8888, true);

                canvas = new Canvas(mutableBmp);
                canvas.DrawColor(canvasColor);

                paint          = new Paint();
                paint.Color    = colorText;
                paint.TextSize = textSize;
                paint.SetTypeface(typefaceDefault);

                canvas.DrawText(text, drawX, drawY, paint);

                return(mutableBmp);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DrawableIcon <T>), ex);
                #endregion

                return(null);
            }
            finally { }
        }
Exemplo n.º 2
0
        private void LayoutNotificationResourceInit()
        {
            try
            {
                remoteViewsEmpty = new RemoteViews(context.PackageName, Resource.Layout.layout_notification_empty);
                remoteViews      = new RemoteViews(context.PackageName, Resource.Layout.layout_notification);

                layoutInflater = LayoutInflater.FromContext(context);
                view           = layoutInflater.Inflate(remoteViews.LayoutId, null);

                textView1 = view.FindViewById <TextView>(Resource.Id.textView1);
                textView2 = view.FindViewById <TextView>(Resource.Id.textView2);
                textView3 = view.FindViewById <TextView>(Resource.Id.textView3);
                textView4 = view.FindViewById <TextView>(Resource.Id.textView4);
                textView5 = view.FindViewById <TextView>(Resource.Id.textView5);
                textView6 = view.FindViewById <TextView>(Resource.Id.textView6);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            View view = inflater.Inflate(Resource.Layout.content_home, null);

            try
            {
                crudSettings = new CrudSettings();
                settings     = Settings.Instance;

                buttonOk        = view.FindViewById <MaterialButton>(Resource.Id.materialButton1);
                buttonOk.Click += HandlerClickButtonOk;

                buttonCancel        = view.FindViewById <MaterialButton>(Resource.Id.materialButton2);
                buttonCancel.Click += HandlerClickButtonCancel;

                return(view);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(HomeFragment), ex);
                #endregion

                return(view);
            }
        }
Exemplo n.º 4
0
        public override void OnReceive(Context context, Intent intent)
        {
            if (Info.IntentActionAlarm == intent.Action)
            {
                try
                {
                    if (!HearServices.IsServiceRunning(typeof(NotifyService), context))
                    {
                        Intent serviceIntent;

                        serviceIntent = new Intent(context, typeof(NotifyService));
                        serviceIntent.SetAction(Info.IntentActionStartService);

                        if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
                        {
                            context.StartForegroundService(serviceIntent);
                        }
                        else
                        {
                            context.StartService(serviceIntent);
                        }
                    }
                }
                catch (Exception ex)
                {
                    #region Logging
                    LogRuntimeAttribute.InLogFiles(typeof(AlarmReceiver), ex);
                    #endregion
                }
                finally  { }
            }
        }
        internal Settings Read()
        {
            Settings settings;

            try
            {
                Java.IO.File file = new Java.IO.File(dataDir);

                if (file.Exists())
                {
                    settings = ReadSpecialFolder();
                }
                else
                {
                    settings = ReadDefault();
                }

                file.Dispose();

                return(settings);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(CrudSettings), ex);
                #endregion


                return(null);
            }
            finally { }
        }
        /// <summary>
        /// Settings Application Default
        /// </summary>
        /// <returns>Settings</returns>
        public Settings ReadDefault()
        {
            Settings settings;

            try
            {
                using (Stream stream = assetManager.Open(Info.FileNameSettings))
                {
                    using (StreamReader streamReader = new StreamReader(stream))
                    {
                        string jsonRead = streamReader.ReadToEnd();
                        settings = JsonConvert.DeserializeObject <Settings>(jsonRead);

                        streamReader.Close();
                        streamReader.Dispose();
                    }

                    stream.Close();
                    stream.Dispose();
                }

                return(settings);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(CrudSettings), ex);
                #endregion

                return(null);
            }
            finally { }
        }
        /// <summary>
        /// Saved Parameters in a Special Application Folder
        /// </summary>
        /// <returns>Settings</returns>
        private Settings ReadSpecialFolder()
        {
            Settings settings;

            try
            {
                using (StreamReader streamReader = new StreamReader(dataDir))
                {
                    string jsonRead = streamReader.ReadToEnd();
                    settings = JsonConvert.DeserializeObject <Settings>(jsonRead);

                    streamReader.Close();
                    streamReader.Dispose();
                }

                return(settings);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(CrudSettings), ex);
                #endregion

                return(null);
            }
            finally { }
        }
Exemplo n.º 8
0
        public DrawableIcon()
        {
            try
            {
                settings = Settings.Instance;

                drawY = 1;
                drawX = 1;

                textSize = 10;

                typefaceDefault = Typeface.Create(Typeface.Monospace, TypefaceStyle.Normal);

                canvasResourceMaterial = Resource.Drawable.transparent32x32;
                colorText   = Color.White;
                canvasColor = Color.Transparent;
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DrawableIcon <T>), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 9
0
        public virtual Icon GenerateIcon(T obj)
        {
            try
            {
                if (obj == null)
                {
                    return(null);
                }

                bmp = DrawableBitmap(obj);
                Icon icon = Icon.CreateWithBitmap(bmp);

                paint.Dispose();
                canvas.Dispose();
                bmp.Dispose();
                mutableBmp.Dispose();

                return(icon);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DrawableIcon <T>), ex);
                #endregion

                return(null);
            }
            finally { }
        }
Exemplo n.º 10
0
        internal async Task <double> AverageCpuUsage()
        {
            try
            {
                string coresPercent = System.String.Empty;

                double countCorePercent = 0;
                double averageUsage     = 0;
                double core             = 0;

                CpuCores = System.Environment.ProcessorCount;
                int coresCpu = CpuCores - 1;

                while (coresCpu > 0)
                {
                    using (RandomAccessFile scalingCurFreq = new RandomAccessFile($"/sys/devices/system/cpu/cpu{coresCpu}/cpufreq/scaling_cur_freq", "r"))
                    {
                        using (RandomAccessFile cpuInfoMaxFreq = new RandomAccessFile($"/sys/devices/system/cpu/cpu{coresCpu}/cpufreq/cpuinfo_max_freq", "r"))
                        {
                            string curfreg = await scalingCurFreq.ReadLineAsync();

                            string maxfreg = await cpuInfoMaxFreq.ReadLineAsync();

                            double currentFreq = double.Parse(curfreg) / 1000;
                            double maxFreq     = double.Parse(maxfreg) / 1000;

                            core = currentFreq * 100 / maxFreq;

                            cpuInfoMaxFreq.Close();
                        }

                        scalingCurFreq.Close();
                    }

                    countCorePercent += core;

                    coresPercent += $"core number {coresCpu}: {core}%\n";

                    coresCpu--;
                }

                averageUsage = countCorePercent / 100 * System.Environment.ProcessorCount;

                return(averageUsage);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(PartLoadInfo), ex);
                #endregion

                return(0);
            }
            finally { }
        }
Exemplo n.º 11
0
 internal void Start(int timeUserMilliseconds)
 {
     try
     {
         workTimer = new System.Threading.Timer((x) => UpdateInfo(), null, 0, timeUserMilliseconds);
     }
     catch (System.Exception ex)
     {
         #region Logging
         LogRuntimeAttribute.InLogFiles(typeof(PartLoad), ex);
         #endregion
     }
     finally { }
 }
Exemplo n.º 12
0
 public CrudSettings()
 {
     try
     {
         personalPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
         dataDir      = String.Concat(new string[] { personalPath, "/", Info.FileNameSettings });
         assetManager = Android.App.Application.Context.Assets;
     }
     catch (System.Exception ex)
     {
         #region Logging
         LogRuntimeAttribute.InLogFiles(typeof(CrudSettings), ex);
         #endregion
     }
     finally { }
 }
        public DrawableIconDigits() : base()
        {
            try
            {
                settings = Settings.Instance;

                this.typefaceDefault = Typeface.CreateFromAsset(Application.Context.Assets, settings.TypefaceDigits);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DrawableIconDigits <T>), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 14
0
 private void AttemptRestart()
 {
     try
     {
         PendingIntent restartServicePendingIntent;
         Intent        startIntent = new Intent(context, typeof(NotifyReceiver));
         startIntent.SetAction(Info.IntentActionRestartServiceRam);
         restartServicePendingIntent = PendingIntent.GetBroadcast(context, 0, startIntent, 0);
         restartServicePendingIntent.Send();
     }
     catch (System.Exception exIntent)
     {
         #region Logging
         LogRuntimeAttribute.InLogFiles(typeof(NotifyService), exIntent);
         #endregion
     }
     finally { }
 }
        private void FillRamView(CancellationToken token)
        {
            try
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(500);

                    Xamarin.Essentials.MainThread.BeginInvokeOnMainThread(
                        delegate
                    {
                        partLoadInfo = new PartLoadInfo();
                        partLoadInfo.UpdateContext();

                        if (partLoadInfo.PercentUsed >= 75)
                        {
                            circularProgress.ProgressColor = Color.DarkRed;
                        }
                        if (partLoadInfo.PercentUsed >= 85)
                        {
                            //cancellationToken.Cancel();
                        }
                        else
                        {
                            circularProgress.ProgressColor = Color.DarkGreen;
                        }

                        ProgressIndicatorUpdate();
                    });

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DashboardFragment), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 16
0
        protected override void UpdateInfo()
        {
            try
            {
                base.UpdateInfo();

                if (RamUpdated?.Target != null)
                {
                    RamUpdated(this, this);
                }
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(PartLoad), ex);
                #endregion
            }
            finally { }
        }
        public override Icon GenerateIcon(T obj)
        {
            try
            {
                if (obj == null)
                {
                    return(null);
                }

                settings = Settings.Instance;

                drawY = settings.Ordinate;
                drawX = settings.Abscissa;

                textSize = settings.TextSizeDigits;

                typefaceDefault = Typeface.CreateFromAsset(Application.Context.Assets, settings.TypefaceDigits);

                canvasResourceMaterial = CanvasConverter.GetResourceDrawableInt(settings.CanvasMaterial);
                colorText   = ColorConverter.GetColorByString(settings.ColorTextDigits);
                canvasColor = ColorConverter.GetColorByString(settings.CanvasColor);

                bmp = DrawableBitmap(obj);
                Icon icon = Icon.CreateWithBitmap(bmp);

                paint.Dispose();
                canvas.Dispose();
                bmp.Dispose();
                mutableBmp.Dispose();

                return(icon);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DrawableIconDigits <T>), ex);
                #endregion

                return(null);
            }
            finally { }
        }
Exemplo n.º 18
0
 private void RemoveNotification()
 {
     try
     {
         if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
         {
             StopForeground(StopForegroundFlags.Remove);
         }
         using (NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService))
         {
             notificationManager.Cancel(Info.NotificationId);
         }
     }
     catch (System.Exception ex)
     {
         #region Logging
         LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
         #endregion
     }
     finally { }
 }
Exemplo n.º 19
0
        internal void Write(Settings settings)
        {
            try
            {
                string jsonWrite = JsonConvert.SerializeObject(settings);

                using (StreamWriter streamWriter = new StreamWriter(dataDir))
                {
                    streamWriter.WriteLine(jsonWrite);

                    streamWriter.Close();
                    streamWriter.Dispose();
                }
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(CrudSettings), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 20
0
        public override void OnDestroy()
        {
            try
            {
                base.OnDestroy();

                alarmManager.Cancel(pendingIntentAlarm);
                handler.RemoveCallbacks(action);
                RemoveNotification();

                StopSelf();
                partLoad.Stop();
                partLoad.RamUpdated -= Updated;
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 21
0
        private async Task UpdateCpuInfo()
        {
            try
            {
                double averageUsage = 0;
                double averageFree  = 0;

                averageUsage = await AverageCpuUsage();

                averageFree = 100 - averageUsage;

                //Update
                CpuUsage = System.Math.Round(averageUsage, 1);
                CpuFree  = System.Math.Round(averageFree, 1);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(PartLoadInfo), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 22
0
        internal bool Delete()
        {
            try
            {
                bool isDeleteFile = false;

                Java.IO.File file = new Java.IO.File(dataDir);
                isDeleteFile = file.Delete();

                file.Dispose();

                return(isDeleteFile);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(CrudSettings), ex);
                #endregion

                return(false);
            }
            finally { }
        }
        protected override Bitmap DrawableBitmap(object obj)
        {
            string text  = string.Empty;
            string toStr = obj.ToString();

            try
            {
                settings = Settings.Instance;

                if (settings.IsRamSelectedNotification == true)
                {
                    if (settings.IsShowRelativeRAM)
                    {
                        text = String.Concat(new string[] { toStr, "%" });
                    }
                    else
                    {
                        text = String.Concat(new string[] { toStr, "Gb" });
                    }
                }
                if (settings.IsCpuSelectedNotification == true)
                {
                    text = String.Concat(new string[] { toStr, "%" });
                }

                return(base.DrawableBitmap(text));
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(DrawableIconDigits <T>), ex);
                #endregion

                return(base.DrawableBitmap(text));
            }
            finally { }
        }
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent.Action == Intent.ActionBootCompleted)
            {
                try
                {
                    settings = Settings.Instance;

                    #region Action starting OS
                    Intent serviceIntent;

                    serviceIntent = new Intent(context, typeof(NotifyService));
                    serviceIntent.SetAction(Info.IntentActionStartService);

                    if (settings.IsAutoStartWhenRebootOS == true)
                    {
                        if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
                        {
                            context.StartForegroundService(serviceIntent);
                        }
                        else
                        {
                            context.StartService(serviceIntent);
                        }
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    #region Logging
                    LogRuntimeAttribute.InLogFiles(typeof(LoadingReceiver), ex);
                    #endregion
                }
                finally { }
            }
        }
Exemplo n.º 25
0
        private async Task UpdateMemoryInfo()
        {
            try
            {
                context = Android.App.Application.Context;

                memoryInfo = new MemoryInfo();

                activityManager = context?.GetSystemService(Context.ActivityService) as ActivityManager;

                activityManager?.GetMemoryInfo(memoryInfo);

                //Update
                AvailableRamBytes = memoryInfo?.AvailMem;
                UsedRamBytes      = TotalRamBytes - AvailableRamBytes;
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(PartLoadInfo), ex);
                #endregion
            }
            finally { }
        }
Exemplo n.º 26
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            try
            {
                RegisterNotification();
                handler.PostDelayed(action, 1);

                return(StartCommandResult.Sticky);
            }
            catch (System.Exception ex)
            {
                #region Attempt restart
                AttemptRestart();
                #endregion

                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
                #endregion

                return(StartCommandResult.Sticky);
            }

            finally { }
        }
Exemplo n.º 27
0
        public override void OnCreate()
        {
            base.OnCreate();

            try
            {
                context  = Android.App.Application.Context;
                partLoad = new PartLoad();
                settings = Settings.Instance;

                #region Layout notification
                LayoutNotificationResourceInit();
                #endregion

                #region Notify Receivers
                NotifyReceiver notifyReceiver = new NotifyReceiver();

                IntentFilter notifyIntentFilter = new IntentFilter("com.arbuz.widram.notifyreceiver");
                notifyIntentFilter.AddAction(Info.IntentActionStopService);
                notifyIntentFilter.AddAction(Info.IntentActionRestartServiceRam);
                notifyIntentFilter.AddAction(Info.IntentActionUpdateSettings);

                context.RegisterReceiver(notifyReceiver, notifyIntentFilter);
                #endregion

                #region  Loading Receivers
                LoadingReceiver loadingReceiver     = new LoadingReceiver();
                IntentFilter    loadingIntentFilter = new IntentFilter(Android.Content.Intent.ActionBootCompleted);
                context.RegisterReceiver(loadingReceiver, loadingIntentFilter);
                #endregion

                #region  Alarm Receivers
                AlarmReceiver alarmReceiver = new AlarmReceiver();

                IntentFilter alarmIntentFilter = new IntentFilter("com.arbuz.widram.alarmreceiver");
                alarmIntentFilter.AddAction(Info.IntentActionAlarm);

                context.RegisterReceiver(alarmReceiver, alarmIntentFilter);

                Intent intentAlarm = new Intent(context, typeof(AlarmReceiver));
                intentAlarm.SetAction(Info.IntentActionAlarm);

                pendingIntentAlarm = PendingIntent.GetBroadcast(context, 0, intentAlarm, PendingIntentFlags.UpdateCurrent);

                alarmManager = (AlarmManager)context.GetSystemService(AlarmService);
                alarmManager.SetRepeating(AlarmType.ElapsedRealtime, 1000, 1000, pendingIntentAlarm); //API 19 Timer not working for setup number
                #endregion

                #region Main
                handler              = new Handler();
                action               = new Action(async() => await OnWork());
                partLoad.RamUpdated += Updated;
                #endregion
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
                #endregion
            }

            finally { }
        }
Exemplo n.º 28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

                Xamarin.Essentials.Platform.Init(this, savedInstanceState);

                SetContentView(Resource.Layout.content_main);

                #region Fragment navigation

                BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);
                navigation?.SetOnNavigationItemSelectedListener(this);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, new HomeFragment())
                .Commit();

                #endregion

                #region Settings

                settings = Settings.Instance;

                #endregion

                #region App Center Crash (http: // appcenter.ms )

                if (settings.IsSendCrashes == true)
                {
                    AppCenter.Start(AppCenterId, new Type[] { typeof(Crashes) });

                    Crashes.SendingErrorReport += (sender, e) => CrashesSendingErrorReport(sender, e);

                    Crashes.ShouldAwaitUserConfirmation = () =>
                    {
                        AndroidX.AppCompat.App.AlertDialog.Builder alert = new AndroidX.AppCompat.App.AlertDialog.Builder(Platform.CurrentActivity);
                        alert.SetTitle("Confirm send");
                        alert.SetMessage("Send anonymous data about crashes in the app?");

                        alert.SetPositiveButton("Send", (senderAlert, args) =>
                        {
                            UserConfirmationDialog(UserConfirmation.Send);

                            Toast.MakeText(context, "Send", ToastLength.Short).Show();
                        });

                        alert.SetNegativeButton("Cancel", (senderAlert, args) =>
                        {
                            UserConfirmationDialog(UserConfirmation.DontSend);

                            Toast.MakeText(context, "Not Send", ToastLength.Short).Show();
                        });

                        Dialog dialog = alert.Create();
                        dialog.Show();

                        return(true);
                    };
                }

                #endregion

                if (settings.IsLogErrorStorage == true)
                {
                    Task.Run(() => PermissionsCheckRun());
                }
            }
            catch (Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(MainActivity), ex);
                #endregion
            }
        }
Exemplo n.º 29
0
        private Icon GenerateIcon(PartLoad e)
        {
            Icon icon;

            try
            {
                settings = Settings.Instance;

                drawableIconDigit = new DrawableIconDigits <long>();

                long ram = 0;

                if (settings.IsRamSelectedNotification == true)
                {
                    if (settings.IsShowFreeRam == true)
                    {
                        if (settings.IsShowRelativeRAM == true)
                        {
                            ram = (long)e.PercentAvailable;
                        }
                        if (settings.IsShowAbsoluteRAM == true)
                        {
                            ram = (long)e.AvailableRamGB;
                        }
                    }
                    else
                    {
                        if (settings.IsShowRelativeRAM == true)
                        {
                            ram = (long)e.PercentUsed;
                        }
                        if (settings.IsShowAbsoluteRAM == true)
                        {
                            ram = (long)e.UsedRamGB;
                        }
                    }
                }
                if (settings.IsCpuSelectedNotification == true)
                {
                    if (settings.IsShowFreeCpu == true)
                    {
                        ram = (long)e.CpuFree;
                    }
                    else
                    {
                        ram = (long)e.CpuUsage;
                    }
                }

                icon = drawableIconDigit.GenerateIcon(ram);

                return(icon);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
                #endregion

                icon = drawableIconDigit.GenerateIcon(0);

                return(icon);
            }
            finally { }
        }
Exemplo n.º 30
0
        private void RegisterNotification(Icon icon = null, PartLoad e = null)
        {
            try
            {
                using (NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService))
                {
                    Notification.Builder notificationBuilder;

                    settings = Settings.Instance;

                    string freeRam  = System.String.Empty;
                    string loadRam  = System.String.Empty;
                    string totalRam = System.String.Empty;
                    string usageCpu = System.String.Empty;
                    string freeCpu  = System.String.Empty;
                    string cpuCores = System.String.Empty;

                    #region Layout notification
                    if (view == null ||
                        textView1 == null || textView2 == null || textView3 == null || textView4 == null || textView5 == null || textView6 == null || remoteViewsEmpty == null || remoteViews == null)
                    {
                        LayoutNotificationResourceInit();
                    }
                    #endregion

                    #region Notification Channel (Support ANDROID VERSION  <  Oreo)
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                    {
                        NotificationChannel channel = new NotificationChannel(Info.Chanlelid, Info.Name, NotificationImportance.Default)
                        {
                            Description = Info.Description
                        };

                        notificationManager.CreateNotificationChannel(channel);
                        notificationBuilder = new Notification.Builder(this, Info.Chanlelid);
                    }
                    else
                    {
                        notificationBuilder = new Notification.Builder(this);
                    }
                    #endregion



                    if (icon == null)
                    {
                        drawableIcon = new DrawableIcon <string>();
                        icon         = drawableIcon.GenerateIcon(System.String.Empty);
                    }

                    if (e != null)
                    {
                        freeRam  = System.String.Concat(new string[] { "Load", ":", " ", e.UsedRamMB.ToString(), "Mb" });;
                        loadRam  = System.String.Concat(new string[] { "Free", ":", " ", e.AvailableRamMB.ToString(), "Mb" });
                        totalRam = System.String.Concat(new string[] { "Total", ":", " ", e.TotalRamMB.ToString(), "Mb" });
                        usageCpu = System.String.Concat(new string[] { "Load", ":", " ", e.CpuUsage.ToString(), " ", "%" });
                        freeCpu  = System.String.Concat(new string[] { "Free", ":", " ", e.CpuFree.ToString(), " ", "%" });
                        cpuCores = System.String.Concat(new string[] { "Cpu", ":", " ", e.CpuCores.ToString(), " ", "cores" });
                    }

                    if (settings.LayoutNotificationEmpty == false)
                    {
                        #region Empty

                        Notification notificationEmpty = notificationBuilder
                                                         .SetCustomContentView(remoteViewsEmpty)
                                                         .SetSmallIcon(icon)
                                                         .SetOngoing(true)
                                                         .SetAutoCancel(false)
                                                         .Build();

                        #region Start Service (Support ANDROID VERSION  <  Oreo)
                        if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                        {
                            StartForeground(Info.NotificationId, notificationEmpty);
                        }
                        else
                        {
                            notificationManager.Notify(Info.NotificationId, notificationEmpty);
                        }
                        #endregion

                        #endregion
                    }
                    else
                    {
                        #region Filling

                        remoteViews.SetTextViewText(textView1.Id, loadRam);
                        remoteViews.SetTextViewText(textView2.Id, freeRam);
                        remoteViews.SetTextViewText(textView3.Id, totalRam);
                        remoteViews.SetTextViewText(textView4.Id, usageCpu);
                        remoteViews.SetTextViewText(textView5.Id, freeCpu);
                        remoteViews.SetTextViewText(textView6.Id, cpuCores);

                        Notification notification = notificationBuilder
                                                    .SetCustomContentView(remoteViews)
                                                    .SetSmallIcon(icon)
                                                    .SetOngoing(true)
                                                    .SetAutoCancel(false)
                                                    .Build();

                        #region Start Service (Support ANDROID VERSION  <  Oreo)
                        if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                        {
                            StartForeground(Info.NotificationId, notification);
                        }
                        else
                        {
                            notificationManager.Notify(Info.NotificationId, notification);
                        }
                        #endregion

                        #endregion
                    }
                }
            }
            catch (System.Exception ex)
            {
                #region Attempt restart
                AttemptRestart();
                #endregion

                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(NotifyService), ex);
                #endregion
            }

            finally { }
        }