DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more

EvenTiles from Start to Finish - Part 16

Maarten Struys user avatar by
Maarten Struys
·
Feb. 29, 12 · Interview
Like (0)
Save
Tweet
Share
2.56K Views

Join the DZone community and get the full member experience.

Join For Free

in the previous episode of this series about how to develop a windows phone application from scratch you learned how to create the ui of a more or less typical about page using expression blend. the about page contains nothing fancy, just a number of textblocks and a few buttons. right now we are ready to add some functionality to the about page to:

  • display the application’s version in a textblock
  • submit an email containing remarks and/or suggestions to the application’s publisher
  • submit a review for the application
  • check marketplace for more applications, available from the same publisher

screen1

in itself, these are all small, relatively easy and partly unrelated actions. however, the latter 3 items, even though different, all have something in common. in order to achieve the desired result, we will make use of functionality that is available in a windows phone, but outside of our application. to use that specific functionality, we will make use of different windows phone launchers . you can think of a launcher as a separate application that can be shared by our applications to allow users to perform some common tasks in a uniform and consistent way. the fact that a launcher starts a separate, built-in application, has some consequences for our application that makes use of the launcher. when the application we launched becomes active, our application will be moved to the background. this means that our application will temporarily be paused and even be tombstoned in low memory / resource situations. since we already took care of properly dealing with our application being moved to the background ( see episode 7 about tombstoning ), this is not a big deal but it is good to realize what is happening under the covers of the windows phone platform.

note: usually launchers are mentioned together with choosers because they provide similar functionality and operate more or less the same. the big difference between them is that a chooser (as the word implies) is capable of selecting some data (for instance a picture) and return the selected item to our application. choosers will be covered in a later episode of eventiles.


as always, it makes a lot of sense to see things in action and to take a look at actual code. that is the reason why, besides these series of blog entries, there are also accompanying videos and sample code available for download.

retrieving the application’s version number

the first goal we want to achieve is to retrieve the version number of our application and display it in the about page. since our application stores its own version number in its manifest file , we want to retrieve it from there.

note: the version number must also be specified when submitting an application to the windows phone marketplace. according to the documentation, this version number must match your application’s version number but maintaining it in your manifest file is a separate activity. there is yet another version number, stored in the application’s assemblyinfo.cs file and modifiable through the project properties. in eventiles we ignore the latter and retrieve the version number immediately from the application’s manifest file.


application version numbers consist of major, minor, build, and revision components. to match the version number as it is showed in the windows phone marketplace, we only want to display the major and minor parts of the application. since the application manifest file is just another xml file, we can easily retrieve the version number from it.

version info in manifest file

<app xmlns=""
     productid="{883385e6-52e5-4835-83db-8a17499b5767}"
     title="eventiles"
     runtimetype="silverlight"
     version="1.0.0.0"
     genre="apps.normal"
     author="maarten struys"
     description="sample description"
     publisher="dotnetfordevices">


to retrieve the version number and to display it in a textblock inside the about page, we can just load the xml from the manifest file and find the value of the version attribute of the app element. the reason why this works is because the application manifest file (wmappmanifest.xml) is deployed to the phone as part of the xap file.

get version from manifest file

private string getversionnumber()
{
    string[] version = xdocument.load("wmappmanifest.xml").root.element("app").attribute("version").value.split('.');
 
    stringbuilder sb = new stringbuilder(version[0]);
    sb.append(".");
    sb.append(version[1]);
    versionnumber = sb.tostring();
 
    return versionnumber;
}
 
private void phoneapplicationpage_loaded(object sender, routedeventargs e)
{
    tbversion.text = getversionnumber();
}


sending an email

a nice feature inside a windows phone application is the possibility for end users to get in touch with you through email. making this as easy as possible for end users might result in you getting some useful feedback about your application and might also increase the user’s satisfaction with your application, which in turn might lead to better and more reviews. to send an email programmatically to a fixed email address is very simple. you simply can make use of the emailcomposetask and even pre-populate information in the email to make it easier for the end user to send out an email. the following code shows how to send an email programmatically:

using the emailcompose task

private void btnemail_click(object sender, routedeventargs e)
{
    stringbuilder sb = new stringbuilder("feedback / support for eventiles ");
    sb.append(versionnumber);
 
    var emailcomposetask = new emailcomposetask
    {
        to = "mstruys@hotmail.com",
        subject = sb.tostring()
    };
    emailcomposetask.show();
}

note: in order to test this functionality, you have to use a physical device. the windows phone emulator will throw an exception when using the email compose task.


submitting a review

if you know how to use one windows phone launcher you basically know how to use them all. since we already saw that sending an email is a very simple operation (creating a new object, setting some properties and calling the show method on the object), submitting a review should not be difficult. the following code shows how to allow your users to submit a review by using the marketplacereviewtask launcher:

submitting a review

private void btnreview_click(object sender, routedeventargs e)
{
    marketplacereviewtask reviewtask = new marketplacereviewtask();
    reviewtask.show();
}

screen2

of course, this code can be extended, for instance by storing in the application settings if a review has already been submitted. if so, we can for instance remove the button to submit a review from the application. we can also verify if we currently have a data connection in order to submit a review. all this functionality is omitted in this sample code.

checking for more applications

using the same approach as described before, we can also allow the user to look for more applications that we already published on the windows phone marketplace. this can be achieved by using the marketplacesearchtask , again in a similar way:

finding apps on marketplace

private void btnmore_click(object sender, routedeventargs e)
{
    var searchtask = new marketplacesearchtask
    {
        contenttype = marketplacecontenttype.applications,
        searchterms = "dotnetfordevices"
    };
    searchtask.show();
}


the marketplacesearchtask is a very nice marketing instrument because you can guide users of your application to other windows phone applications you have published.

the following video shows how to create the functionality we described in this episode of eventiles. it also shows two of the described launchers in action, one running in the emulator, one on a physical device.



to be able to experiment with this working implementation of eventiles, especially to understand how the application interacts with the periodictask through a file in isolatedstorage, the sample code is available for dowload here . in the next episode of eventiles we will talk about implementing trial mode in your application to allow users to try the application before optionally buying it.

eventiles if you want to see eventiles already in action on your windows phone, you can also install the latest free version from marketplace. remember that this application is not meant to be extremely useful, although it contains similar functionality that “serious” applications have. just go ahead and get your free copy of eventiles from marketplace at this location: http://www.windowsphone.com/en-us/search?q=eventiles (or search on your phone for eventiles in the marketplace application).




application Windows Phone Manifest file

Published at DZone with permission of Maarten Struys, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Is DevOps Dead?
  • Introduction to Automation Testing Strategies for Microservices
  • Testing Repository Adapters With Hexagonal Architecture
  • Create Spider Chart With ReactJS

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: