Metro Nuggets

Bitesized tidbits for building Modern (Metro) apps.

Tango (7.1.1): Detecting Devices With 256MB

Windows Phone update codenamed Tango is coming soon and with it comes devices that have a lower amount of memory in them than the usual 512mb, specifically 256mb. Your app needs to take into account whether it should be able to run on phones with 256mb of RAM and is discussed pretty well on MSDN at http://msdn.microsoft.com/en-us/library/hh855081(VS.92).aspx. So is there a quick way in your app of seeing whether the device your app is running on is 256 or 512mb? Yes, and is touched on in that MSDN link, I decided to just extend the code they give to give a quick and easy property that you can have in your app/viewmodel.

The Solution

Really simple, add this to your using list:

using Microsoft.Phone.Info;

Then simply add this property:

public bool Is512Mb
{
    get
    {
        try
        {
            long result = (long)DeviceExtendedProperties.GetValue("ApplicationWorkingSetLimit");
            return result > 94371840; // 94371840 (90mb) is the maximum a 256mb device will have
        }
        catch (ArgumentOutOfRangeException)
        {
            // The device has not received the OS update, which means the device is a 512-MB device.}
            return true;
        }
    }
}

That’s it really.

SL

Advertisements

3 responses to “Tango (7.1.1): Detecting Devices With 256MB

  1. Pingback: Tango (7.1.1): Detecting Devices With 256MB

  2. mareinsula July 12, 2012 at 06:50

    I have received that I cannot use the ScheduledActionService in 256, so no Live Tiles update for these devices, so no Live Tiles in 256. That’s not a Windows Phone. Thank you for the tip

    • scottisafool July 12, 2012 at 11:51

      Live Tiles can be used on 256mb devices, but they have to come from Push Notifications. It’s only the BackgroundAgent way of updating a Tile that can’t be done.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: