Example #1
0
        public float GetMemory()
        {
            var activityManager = Android.App.Application.Context.GetSystemService(Android.App.Activity.ActivityService) as Android.App.ActivityManager;

            Android.App.ActivityManager.MemoryInfo memoryInfo = new Android.App.ActivityManager.MemoryInfo();
            activityManager.GetMemoryInfo(memoryInfo);
            return(memoryInfo.TotalMem / (1024 * 1024));
        }
Example #2
0
            public static bool CheckMemoryLow(Context ctx)
            {
                try {
                    var am = (Android.App.ActivityManager)ctx.GetSystemService(
                        Android.Content.Context.ActivityService);
                    var memInfo = new Android.App.ActivityManager.MemoryInfo();
                    am.GetMemoryInfo(memInfo);

                    return(memInfo.LowMemory);
                } catch (Java.Lang.Throwable ex) {
                    Log.Warn(Tag, ex, "Failed to determine low memory state.");
                    return(false);
                }
            }
Example #3
0
        string getRam(Context context)
        {
            StringBuilder sb = new StringBuilder();

            try {
                Android.App.ActivityManager.MemoryInfo memInfo    = new Android.App.ActivityManager.MemoryInfo();
                Android.App.ActivityManager            actManager = context.GetSystemService(Android.Content.Context.ActivityService) as Android.App.ActivityManager;
                actManager.GetMemoryInfo(memInfo);
                sb.AppendLine(getItemString("RAM:", string.Format("{0} B ({1:N1} kb / {2:N1} MB / {3:N1} GB)",
                                                                  memInfo.TotalMem,
                                                                  memInfo.TotalMem / 1024.0,
                                                                  memInfo.TotalMem / (1024.0 * 1024.0),
                                                                  memInfo.TotalMem / (1024.0 * 1024.0 * 1024.0)), NAME1POS, CONTENT1POS));
            } catch (Exception ex) {
                sb.AppendLine("Exception: " + ex.Message);
            }
            return(sb.ToString());
        }
Example #4
0
        static void SendLog(WebException ex, string messResult, string method, string url, string data)
        {
            //			string method = request.Method;
            //			string url = request.RequestUri.OriginalString;
            //			string data = null;
            if (method == "GET")
            {
                data = null;
            }
            string message;

            if (ex.Response != null)
            {
                message = messResult;
            }
            //message = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
            else
            {
                message = ex.Message;
            }

            string methodShow = null;
            string exClass    = null;

            if (ex.TargetSite != null)
            {
                methodShow = ex.TargetSite.Name;
                exClass    = ex.TargetSite.DeclaringType.FullName;
            }
            string pageHistory;

            if (OnePage.redirectApp != null)
            {
                pageHistory = OnePage.redirectApp.GetHistoryToJson();
            }
            else
            {
                pageHistory = "нету";
            }
            AppsLog log = new AppsLog {
                SystemName     = Device.OS.ToString(),
                ExceptionType  = ex.GetType().ToString(),
                StackTrace     = ex.StackTrace,
                Message        = message,
                AdditionalData = @"""  """,
                PageHistory    = pageHistory,
                AppVersion     = App.Version,
                AppFunction    = exClass + "." + methodShow,
                TypeError      = "TypeWeb",
                UserId         = User.Singleton == null ? 0 : User.Singleton.Id,
                UseKey         = User.Singleton?.HashKey,
                UrlApp         = url,
                UrlMethod      = method,
                UrlData        = data
            };

                        #if __ANDROID__
            var activityManager = Android.App.Application.Context.GetSystemService(Android.App.Activity.ActivityService) as Android.App.ActivityManager;
            Android.App.ActivityManager.MemoryInfo memoryInfo = new Android.App.ActivityManager.MemoryInfo();
            activityManager.GetMemoryInfo(memoryInfo);
            double totalUsed = memoryInfo.AvailMem / (1024 * 1024);
            double totalRam  = memoryInfo.TotalMem / (1024 * 1024);

            log.DeviceModel   = Android.OS.Build.Model;
            log.SystemVersion = Android.OS.Build.VERSION.Sdk;
            log.SizeMemory    = totalUsed.ToString("f2") + "/" + totalRam.ToString("f2");
                        #elif __IOS__
            log.DeviceModel   = UIKit.UIDevice.CurrentDevice.Name;
            log.SystemVersion = UIKit.UIDevice.CurrentDevice.SystemVersion;
            log.SizeMemory    = (Foundation.NSProcessInfo.ProcessInfo.PhysicalMemory / (1024 * 1024)).ToString("f2");
                        #endif
            AppsLog.SendLog(log);
        }
Example #5
0
            public static bool CheckMemoryLow (Context ctx)
            {
                try {
                    var am = (Android.App.ActivityManager)ctx.GetSystemService (
                                 Android.Content.Context.ActivityService);
                    var memInfo = new Android.App.ActivityManager.MemoryInfo ();
                    am.GetMemoryInfo (memInfo);

                    return memInfo.LowMemory;
                } catch (Java.Lang.Throwable ex) {
                    Log.Warn (Tag, ex, "Failed to determine low memory state.");
                    return false;
                }
            }