Over a million developers have joined DZone.

Determining license mode in Windows Phone 7 apps

· Mobile Zone

Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud, brought to you in partnership with IBM.

In this post I will show how to separate trial license functionality from full license functionality in Windows Phone 7 applications. Application submitted to a marketplace could be provided with a trial version, so any user can try it before buying.

Additional


Adding a marketplace namespace

Next you need to add a marketplace namespace within MainPage.xaml (or any other xaml file).

using Microsoft.Phone.Marketplace;

Determining a type of license

Now you can determine a type of license (application mode) using the following code:

if (new LicenseInformation().IsTrial())
{
    // trial mode (trial license)
}
else
{
    // full mode
}

Property

Next I would like to share the property I use in my Windows Phone application to determine if application is in trial mode and to simulate the trial mode for emulator. You can modify the boolean value of _emulatorIsTrial variable to switch emulator between trial and full version.

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

Source: http://www.eugenedotnet.com/2010/09/w10-determining-license-mode-in-windows-phone-7-apps/


The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}