Create a WP8 trial app

Source: Internet
Author: User

Resources:

Create a trial app for Windows Phone

How to implement a trial experience in a Windows Phone app

Windows Phone 7 Development 31st talk--23rd day: Provide a trial version of the app

Summary of the information:

How to check the trial license in your app:

Add the following two lines in the App.xaml.cs

Using Microsoft.Phone.Marketplace;

Private static LicenseInformation _licenseinfo = new LicenseInformation ();

Use the _licenseinfo.istrial () method, which reads the Istrial property on the LicenseInformation object, returns True when it is a trial version, otherwise a paid version

But actually when debugging, the app's real license information is only available after it is published to the store, so the following two pieces of code are used in App.xaml.cs. After use, the code between # if Debug and #else will be executed when it is debugged, the manual setting is a trial version, and the code between #else and #endif is executed when in release mode. That is, the Istrial property on the LicenseInformation object is read to set whether the trial version.

        Private Static BOOL true ;          Public BOOL istrial        {            get            {                return  _istrial;            }        }
        /// <summary>        ///Check The current license information for this application/// </summary>        Private voidChecklicense () {//When debugging, we want to simulate a trial mode experience. The following conditional allows us to set the _istrial//simulate trial mode being on or off.#ifDEBUGstringMessage ="This is sample demonstrates the implementation of a trial mode in an application."+"Press ' OK ' to simulate trial mode. Press ' Cancel ' to run the application in normal mode."; if(MessageBox.Show (Message,"Debug Trial", Messageboxbutton.okcancel)==Messageboxresult.ok) {_istrial=true; }            Else{_istrial=false; }#else_istrial=_licenseinfo.istrial ();#endif        }

The app's license needs to be checked when the app starts or resumes:

That is, to add a trial version of the application_launching and application_activated events in App.xaml.cs checklicense()

Use the current app's license information:

Because the Istrial property is set in App.xaml.cs to read the license properties, we can use the (application.current as App). The Istrial property is used to obtain the license information for the app directly, avoiding the reuse of the Istrial () method, which takes 60 milliseconds or more to a typical call.

Create a WP8 trial app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.