Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Three properties that I use for almost every Windows Phone application

DZone's Guide to

Three properties that I use for almost every Windows Phone application

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

In this post I will tell you which three properties I use for almost every one of my Windows Phone applications. The first property is used by me to determine if the application is running in trial mode or full mode. Second property is provided to identify if the application is running on low-memory device and the last property is used to detect if user has selected a dark or light background theme in Windows Phone settings. All of those properties were described in detail earlier, but I have decided to collect them in a single post.

Is it the trial version or full version?

A few months ago I wrote a post Determining license mode in Windows Phone 7 apps and below is a property taken from that post. You can simulate if application is running in Emulator in trial mode by modifying the “emulatorIsTrial” variable.

private const bool _emulatorIsTrial = false;
 
public bool IsTrialMode
{
    get
    {
        if (Microsoft.Devices.Environment.DeviceType
               == Microsoft.Devices.DeviceType.Emulator)
        {
            return _emulatorIsTrial;
        }
        return (new LicenseInformation().IsTrial());
    }
}

 

Is it a low memory device?

To take advantage of devices that have more than 256 Mb of RAM available I have created a special property in one of my previous posts. This property helps you to determine the available memory on a device. Here’s what this property looks like:

private const bool _emulatorIsLowMemory = false;
 
public bool IsLowMemoryDevice
{
    get
    {
        if (Microsoft.Devices.Environment.DeviceType
            == Microsoft.Devices.DeviceType.Emulator)
        {
            return _emulatorIsLowMemory;
        }
        else
        {
            return (long)DeviceExtendedProperties.GetValue("DeviceTotalMemory")
                <= 268435456;
        }
    }
}

Is it a light or dark theme?

Finally, here is a property from my last post to detect if the user has selected a dark or light theme background in Windows Phone settings.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Jevgeni Tšaikin. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}