Beispiel #1
0
        public static bool IsServiceRunning(System.Type typeIntentClass, Context context)
        {
            try
            {
                ActivityManager manager = (ActivityManager)context.GetSystemService(Context.ActivityService);

                foreach (var service in manager.GetRunningServices(int.MaxValue))
                {
                    if (service.Service.ClassName.Equals(Java.Lang.Class.FromType(typeIntentClass).CanonicalName))
                    {
                        return(true);
                    }
                }

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

                return(false);
            }
            finally { }
        }
Beispiel #2
0
        static Info()
        {
            try
            {
                Context context = Android.App.Application.Context;

                AppCenterId                   = context.Resources.GetString(Resource.String.AppCenterId);
                FileNameSettings              = context.Resources.GetString(Resource.String.name_settings_file);
                ApplicationName               = context.Resources.GetString(Resource.String.app_name);
                Name                          = context.Resources.GetString(Resource.String.ChannelNameRam);
                Description                   = context.Resources.GetString(Resource.String.ChannelDescriptionRam);
                Chanlelid                     = context.Resources.GetString(Resource.String.ChannelIDRam);
                NotificationId                = context.Resources.GetInteger(Resource.Integer.IntegerNotificationRamID);
                IntentActionAlarm             = context.Resources.GetString(Resource.String.IntentActionAlarm);
                IntentActionUpdateSettings    = context.Resources.GetString(Resource.String.IntentActionUpdateSettings);
                IntentActionStartService      = context.Resources.GetString(Resource.String.IntentActionStartServiceRam);
                IntentActionStopService       = context.Resources.GetString(Resource.String.IntentActionStopServiceRam);
                IntentActionRestartServiceRam = context.Resources.GetString(Resource.String.IntentActionRestartServiceRam);
                ActionMainActivity            = context.Resources.GetString(Resource.String.ActionMainActivity);
                ServiceStartedKey             = context.Resources.GetString(Resource.String.ServiceStartedKey);
                ServiceBoundedKey             = context.Resources.GetString(Resource.String.ServiceBoundedKey);
                BroadcastMessengeKey          = context.Resources.GetString(Resource.String.BroadcastMessengeKey);
            }
            catch (System.Exception ex)
            {
                #region Logging
                LogRuntimeAttribute.InLogFiles(typeof(Info), ex);
                #endregion
            }
            finally { }
        }
        public static async void InLogFiles(Type type, Exception exception)
        {
            string pathCurrentFolder = String.Empty;
            string pathCurrentFile   = String.Empty;

            settings = Settings.Instance;

            try
            {
                if (settings.IsLogErrorStorage == true)
                {
                    TypeInfo typeInfo = type.GetTypeInfo();

                    TypeAttributes typeAttributes = typeInfo.Attributes;
                    object[]       attributes     = typeInfo.GetCustomAttributes(true);

                    if (attributes != null)
                    {
                        foreach (var item in attributes)
                        {
                            if (item.ToString() == (typeof(LogRuntimeAttribute)).FullName)
                            {
                                LogRuntimeAttribute logRun = (LogRuntimeAttribute)item;

                                pathCurrentFolder = logRun.PathFolder;
                                pathCurrentFile   = logRun.PathFile;

                                break;
                            }
                        }
                    }


                    PermissionStatus status = await Permissions.CheckStatusAsync <Permissions.StorageWrite>();

                    if (status == PermissionStatus.Granted)
                    {
                        if (pathCurrentFile != String.Empty)
                        {
                            Java.IO.File file = new Java.IO.File(pathCurrentFolder);

                            file.Mkdir();

                            file = new Java.IO.File(pathCurrentFile);
                            file.CreateNewFile();

                            FileWriter writer = new FileWriter(file);

                            writer.Write(exception.ToString());
                            writer.Flush();


                            file.Dispose();
                            writer.Close();
                            writer.Dispose();
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
            finally { }
        }