Free Online Courses for Software Developers - MrBool
× Please, log in to give us a feedback. Click here to login
×

You must be logged to download. Click here to login

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

How to Create a Trial Application for Windows Phone 7

The article aims to teach developers how a trial application can be build for Windows Phone 7 and also the points that need to be noted in order to avoid its failure.

Let us try to learn the things such as why the trial state of application needs to be cached; things that should be kept in mind at the time when you are building trial apps etc.

What is a trial mode? Well, Trial mode allows the end user of the application to make use of the same before they go and buy it. With the help of the platform that the Windows Phone uses, it helps the developers to incorporate a trial facility to the application. The time when you will be positing the Windows Phone 7 application to the Marketplace, it gives you an option in case you want to permit the trial licenses for the application you are going to submit. You would just need to check the checkbox present against the Trial Application option. This will in turn display a Try like option view in the Marketplace on the application detail page. The good thing is you would never see the trial license getting expired. In fact the same would be replaced by a full license as and when the application is purchased by a customer.

The Beginning of Creating a Windows Phone 7 Trial Application

It has become really simple and easy to make our plans of implementing applications in a trial mode with the helping hand of Microsoft.Phone.License.LicenseInfo class. It is nothing but that exposes the IsTrial() method. Exactly to what the name suggests, the task of the method is to give back a bool value. This bool value shows that if the application is running in a trial mode or not. It would return True in case the application is in trial mode else it will return False.

Let us go step by step to see how we can create a trail application for Windows Phone 7 that will be completely functional.

Step 1: The very first thing you need to do is to Consider!: Make certain and bear in mind that the time when you are going to come up with a trial mode application, the attributes such as Application Lifecycle, performance of the application, the back button feature would need to be given a serious consideration. The entire process would look as below:

Representing the Application Lifecycle

Figure 1: Representing the Application Lifecycle As far as the performance of the application is concerned, the vital thing is to consider here is the state of the IsTrial() that should be “Cache”. If we talk about the time that a regular call to IsTrial() is taken, it is near to 60 milliseconds. This means that in case this method is called on a frequent basis i.e. to check every time that the application is running in a trial mode, this will really lead to some bad statistical figures as far as performance is concerned and could even lead to clearing the certification for our application.

Step 2: Construct a static bool attribute in App.xaml.cs so as to Cache the trial state.

In order to get access to the trial state in the easiest of the manners and to make caching possible, the static property should be used. The example includes the creation of IsTrial property in App.xaml.csz. This is done with private setter that makes certain that the setting of IsTrial property is not permitted from outside.

public static bool IsTrial
{
    get;
    // setting the IsTrial property is not permitted from outside
    private set;
}

Step 3: Figure out if the app is in Trial state

The need is to create a method in App.xaml.cs that would verify the value of the Microsoft.Phone.Marketplace.LicenseInformation IsTrial() method. In other words, it will help in figuring out whether the application is in Trial mode or no. It would return True if in Trial else False). The point to note here is that at the time of debugging with trail enabled, the value will be returned a true.

private void DetermineIsTrail()
{
#if TRIAL
    // return true in case debugging with trial enabled
    IsTrial = true;
#else
    var license = new Microsoft.Phone.Marketplace.LicenseInformation();
    IsTrial = license.IsTrial();
#endif
}

NOTE: The value will be returned as FALSE in case the application is run while it is being developed (in the emulator). To troubleshoot this, the requirement is to hard code the method to return TRUE at the time of debugging as explained above.

Step4: You must Cache/Refresh IsTrial() on the correct place!

The significant thing that should be done is to "refresh" the state of the IsTrial() on the correct place:

The value of the IsTrial property needs to be refreshed when the application is

  • launched - Application_Launching handler
  • activated - Application_Activated handler
// Code to run at the time when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
    // refresh the value of the IsTrial property when the application is launched
    DetermineIsTrail();
}
 
// Code to run at the time when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
    // refresh the value of the IsTrial property when the application is activated
    DetermineIsTrail();

NOTE: The important thing to make sure over here is that one should not forget to Cache IsTrial() the moment the app is launched and activated. Otherwise, the launched application app will not work correctly. The below lists that needs to be done and what needs to be added

public static bool IsTrial
{  get;    private set;}
 
private void DetermineIsTrail()
{
#if TRIAL
    IsTrial = true;
#else
    var license = new Microsoft.Phone.Marketplace.LicenseInformation();
    IsTrial = license.IsTrial();
#endif
}
 
private void Application_Launching(object sender, LaunchingEventArgs e)
{
    DetermineIsTrail();
}
 
private void Application_Activated(object sender, ActivatedEventArgs e)
{
    DetermineIsTrail();
}

Conclusion

The article explained the process to create a trial application for Windows Phone 7 and points that needs to be noted in order to avoid its failure.



I am a software developer from India with hands on experience on java, html for over 5 years.

What did you think of this post?
Services
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits
[Close]
You must be logged to download.

Click here to login