检测低内存设备

时间:2012-10-11 06:50:07

标签: windows-phone-7 live-tile

我正在尝试删除在我的应用中为运行低内存设备(如诺基亚Lumia 610)的用户启用实时磁贴的选项。我使用的是从微软获得的以下代码,但运行Lumia 800和Focus i917的一些用户报告说,添加此功能后,实时磁贴功能消失了。

检测低内存设备的正确方法是什么?

这是我正在使用的代码,它显然适用于模拟器和大多数用户,但并非适用于所有用户:

long result = 0;

try
{
    result = (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
}
catch (ArgumentOutOfRangeException)
{
    //The device has not received the OS update, which means the device is a 512-MB device.
}

if (result < 90000000)
{
    //Low memory device
}

1 个答案:

答案 0 :(得分:5)

我使用此代码。问题可能在于常量,我的是来自MSDN页面的低内存设备:Developing for 256-MB Devices

/// <summary>
/// Flag if device is Low-memory Tango device or not.
/// </summary>
public static bool IsLowMemDevice
{
    get
    {
        if (!isLowMemDevice.HasValue)
        {
            try
            {
                // check the working set limit 
                long result = (long) DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
                isLowMemDevice = result < 94371840L;
            }
            catch (ArgumentOutOfRangeException)
            {
                // OS does not support this call => indicates a 512 MB device
                isLowMemDevice = false;
            }
        }
        return isLowMemDevice.Value;
    }
}
private static bool? isLowMemDevice;