Created
October 9, 2017 10:42
-
-
Save mogwai/6598138c623fc027e0e02a917c8ab571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyApp.Helpers { | |
public static class DeviceInformation { | |
/// <summary> | |
/// Finds out whether this is a low memory device using a Dependency Service | |
/// </summary> | |
[Preserve] | |
public static bool LowMemoryDevice { | |
get { | |
var mem = DependencyService.Get<IMemoryHelper>().GetTotalMemory(); | |
mem = mem / (1000 * 1000);// To megabytes | |
Debug.WriteLine($"Total Memory: {mem}MB"); | |
return mem < 500; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly:Dependency(typeof(MemoryHelper))] | |
namespace MyApp.iOS.Helpers { | |
[Preserve(AllMembers = true)] | |
public class MemoryHelper : IMemoryHelper { | |
public MemoryHelper() { } | |
public ulong GetTotalMemory() { | |
return NSProcessInfo.ProcessInfo.PhysicalMemory; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment