Welcome!

.NET Authors: Ivan Antsipau, JP Morgenthal, Sandi Mappic, Yeshim Deniz, Carmen Gonzalez

Related Topics: .NET

.NET: Article

Windows Mobile Version 5.0 Revealed

Improved productivity, integrated multimedia, and diverse customization experiences

There has never been an operating system release more important to .NET developers than the release of Windows Mobile Version 5.0. With this release, Microsoft is poised to take your productivity in writing mobile applications higher than it has ever gone before. Rich multimedia capabilities, integrated messaging, and world-class telephony support are just a few of the benefits you will realize when you develop applications for the Windows Mobile 5.0 platform.

From the perspective of the .NET software developer, perhaps the most important piece of Windows Mobile 5.0 is its brand new Managed API. All of the code for this new API is found in the Microsoft.WindowsMobile namespace. You can access this API from Visual Studio by adding references to the following assemblies:

  • Microsoft.WindowsMobile.Configuration
  • Microsoft.WindowsMobile.Forms
  • Microsoft.WindowsMobile.PocketOutlook
  • Microsoft.WindowsMobile.Status
  • Microsoft.WindowsMobile.Telephony
The Windows Mobile 5.0 Managed API is compatible with .NET Compact Framework 1.0, as well as with .NET Compact Framework 2.0, although you must use Visual Studio 2005 to target Windows Mobile 5.0 and to use the new managed APIs.

Telephony

Of the four Windows Mobile-based devices I [Derek] have owned over the past few years, three of them have been telephony-enabled devices. The first two of these were Pocket PC Phone Edition devices, so named because they were essentially Pocket PCs that just happened to support making and receiving telephone calls.

My most recent acquisition is a Windows Mobile 2003 Second Edition-based Smartphone. The Smartphone is an amazingly capable device that allows me to send and receive MSN Messenger messages, take pictures, and run software written using the .NET Compact Framework, in addition to the traditional telephony functions of placing and receiving telephone calls.

Before Windows Mobile 5.0, however, Windows Mobile Software for Pocket PC Phone Edition or Smartphone did not support direct access to telephony functionality via a managed API. So prior to Windows Mobile 5.0, if one wanted to create a .NET Compact Framework application that, for example, dialed a given telephone number, one would typically have had to access a native API for this purpose via .NET's p/Invoke functionality.

Windows Mobile 5.0 addresses this by providing a namespace called Microsoft.WindowsMobile.Telephony as a part of its base functionality. At the time of writing, this namespace consists of a single class called Phone, which exposes a single method, called Talk. Talk takes a String parameter representing the telephone number to be dialed, plus an optional Boolean parameter specifying whether or not the user should be prompted prior to dialing.

For example, the following line of C# code will dial the number for operator assistance in most major U.S. cities. Prior to dialing, however, a confirmation dialog will be displayed to the user.


new Phone().Talk("555-1212", true);

Outlook Mobile

The ability to store information about contacts and to communicate with them is central to the functionality of both major device types (Smartphones and Personal Digital Assistants - PDAs) currently targeted by the .NET Compact Framework. On the Windows desktop, Microsoft Outlook is the application of choice for storing contact information and for communicating via e-mail. Under Windows Mobile, this functionality is performed by Outlook Mobile, with added functionality for communication via the Short Message Service (SMS), a kind of instant messaging tailor-made for use with mobile devices.

Prior to Windows Mobile 5.0, there was no managed interface for Outlook Mobile. To be sure, alternative approaches for accessing contacts under Windows Mobile have been developed. Developers could native code, p/Invoke, or - under Visual Studio 2005 - use COM Interop to tap into the rich messaging and contact management functionality provided by Outlook Mobile. Third-party vendors (see Resources at the end of this article) have also developed and sold Outlook Mobile access libraries for the .NET Compact Framework.

With the release of Windows Mobile 5.0, developers for the first time have a managed API baked directly into the operating system to facilitate all Personal Information Management (PIM) functionality available in the Windows Mobile operating system.

The Pocket Outlook Object Model

The core managed APIs for interacting with Outlook Mobile on Windows Mobile 5.0 are all contained in the Microsoft.WindowsMobile.PocketOutlook namespace (the name is a throwback to the old name for Outlook Mobile, Pocket Outlook). In general, there is one unique class for dealing with each kind of entity in Outlook Mobile.

To briefly summarize the kinds of classes in as few words as possible, consider the path that a message will typically take from Outlook Mobile to a recipient aw well as its path in the opposite direction. The trip begins (or ends) with either an e-mail or an SMS account, because these are the two protocols supported by Outlook Mobile. For this reason, there are EmailAccount and SmsAccount classes in the PocketOutlook namespace.

To create an actual message, there are EmailMessage and SmsMessage classes, as well as classes for working with such messages' associated entities. For example, there are classes for things such as recipients and attachments. A brief example of sending an e-mail using some of these classes is shown in Listing 1.

Listing 1 begins by creating an Outlook Session. This is a central class in working with Outlook Mobile's managed API, and you will generally always instantiate this class whenever you work with Outlook Mobile.

We then instantiate an instance of EmailMessage to represent the message we wish to send, and an instance of Recipient to represent the person to whom we wish to send our message. We set the text of the message's body, associate the recipient with the message, then use the account named "PersonalAccount" (which we got from the Outlook Session) to send our e-mail.

Besides messages, Outlook Mobile also facilitates the tracking of appointments and tasks. There are classes for both of these things, as well as a host of supporting classes for details such as their recurrence schedules.

Finally, many of the classes described above also have collection classes for dealing with their instances as a group. TaskCollection, ContactCollection, and Appointment-Collection would be good examples of such classes.

Intercepting Messages

A recent client was very concerned about their potential loss of intellectual property if one of their organization's devices were ever lost or stolen. They wanted to be able to completely wipe (perform a "cold reset" upon) a device that had gone beyond their physical control simply by sending it an SMS message with a special secret code in its body.

The class that allows a developer to build this kind of functionality in Windows Mobile 5.0 is known as MessageInterceptor and lives in the Microsoft.WindowsMobile.PocketOutlook.MessageInterception namespace. This namespace is all about writing code that waits to receive a message, and then performing some kind of work.

The workflow to achieve this is fairly simple. First, one must instantiate a MessageInterceptor object. There are two main points of interest on this object. First, its MessageCondition property allows a developer to specify the kind of message to which such an object should respond. The interceptor can be set to respond to a message with a Body, Sender, or Subject that matches - or explicitly doesn't match - a given value.

The other interesting feature of this class is its EnableApplication-Launcher method. By calling this method, you can register your application to be launched when a specified message is received. This allows you to intercept messages without having to keep your applications running in the background.

Managed Configuration Manager

Carriers and corporate support groups will want to interact with the Configuration Manager in order to set up a device with different characteristics. The potential areas of configuration include user settings and device settings like connectivity parameters, security, and the ability to uninstall an application. These settings are contained in XML files that need to be passed into the Configuration Manager. The explanation of this topic would require more than an article, so we'll just point out that the ConfigurationManager class (in the Microsoft.WindowsMobile.ConfigurationManager namespace) is your managed entry point to this functionality.

Using Windows Mobile 5.0 UI in My Applications

As we've mentioned earlier, Window Mobile 5.0 has the first managed API for dealing with Outlook Mobile. This API is extended into the UI tier of Windows Mobile 5.0, and joined by some new dialogs for enhanced multimedia functionality. These APIs are found in System.WindowsMobile.Forms, and include three new dialogs: ChooseContactDialog, SelectPictureDialog, and Camera-CaptureDialog.

To set the stage for this discussion, let's assume that you manage a group of volunteer authors while on the road traveling between your client's city and your home, and it's time to start planning the next issue of your magazine. (This should sound familiar to Derek!) You open up your application on your Windows Mobile 5.0-based device, go to the Start New Issue screen, and start entering data.

One of the enhancements that consumers will notice immediately with Window Mobile 5.0 is that of Outlook Mobile. With the managed interface to this functionality, developers will obviously build PIM and business applications that extend the notion of Contacts. Also, since this application stores the authors as Contacts, we'll use the ChooseContactDialog class to select the authors for this issue. The ChooseContactDialog class does several different things with Contacts, so we'll set up the properties to only select the Contact and then call ShowDialog to get the window started. (See Listing 2 and Figure 1.)

Later, the magazine editor might want to send the author's picture to the printing company. As you'll find out, Windows Mobile 5.0 has an application for selecting and viewing images - and we can use that too. The SelectPictureDialog class provides intuitive functionality like setting the directory to look in, controlling the folder navigation, the title to have on the selection screen, and the chosen image. (See Listing 3.)

Finally, let's say that the magazine editor is at a conference and recruits a new author. The editor knows that at some point that we'll need a headshot. Instead of having to ask later, the editor decides to take advantage of our application and use the integrated camera. By building a screen that calls the CameraCaptureDialog class the application will interact with the device's built-in camera and provides an image file of the author. This is a huge improvement over having to P/Invoke into the OEM's camera API DLL, if they provided one.

Filling in the Gaps of .NET Compact Framework 1.0

Derek and Jon have both written and talked about the missing areas in the .NET Compact Framework. These gaps became the subject of many whitepapers on the MSDN Mobility site. The Microsoft.WindowsMobile.Status solves the majority of these by providing several classes that manage access to system properties. Thus, a developer can now easily retrieve the current ActiveSync status, the display orientation, power state and battery strength, phone information, calendar and task information, messaging and connectivity information, and more. The vastness of the list is impressive. Throw in a few enumerations, and it's as easy as:


If SystemState.ActiveSyncStatus =
ActiveSyncStatus.Synchronizing Then
'Wait for new files
End If

Another way to interact with these properties is to have the SystemState class deliver a notification about a monitored property. For example:


Dim oStatus As New SystemState(System Property.PhoneGprsCoverage)
AddHandler(oStatus.Changed, addressof me.GprsCoverageChange)

The SystemState class also exposes an EnableApplicationLauncher method similar to that exposed by the MessageInterceptor class described above. The difference is, however, that the events that can trigger an application's launch using this method are much more diverse than simply the receipt of a given e-mail or SMS message. This is functionality that many desktop Windows developers would envy!

There are more topics for discussion in the Status namespace. However with these three options, I believe that the SystemState class will be of great interest to those of us who have already been working with the .NET Compact Framework.

Conclusion

As you have seen, Windows Mobile 5.0 will deliver a development experience that is superior to anything available on competing mobility platforms. The availability of managed APIs and a development tool as powerful as Visual Studio 2005 represents the highest level of developer productivity currently available. The integration of multimedia facilities, such as the CameraCaptureDialog described above, will facilitate the creation of rich multimedia applications. And finally, the wide range of application and customization experiences that Windows Mobile 5.0 will make available will allow Microsoft partners and customers to differentiate their offerings in ways previously unimagined. Stay tuned to the MSDN Mobile and Embedded Developer Center for information on the tools to build Windows Mobile 2005 applications.

Resources

Outlook Mobile-related Links
For those of you who need to support Outlook Mobile integration using .NET Compact Framework 2.0, but prior to Windows Mobile 5.0, check out Steven Pratschner's blog for a sample using COM Interop to achieve this.
  • Steven Pratschner's Blog: http://blogs.msdn.com/stevenpr

    For the many of you who will need to support Outlook Mobile integration prior to .NET Compact Framework 2.0, check out this product.

  • PocketOutlook In the Hand: www.inthehand.com/index.php?page=6&show=1,2
  • More Stories By Derek Ferguson

    Derek Ferguson, founding editor and editor-in-chief of .Net Developer's Journal, is a noted technology expert and former Microsoft MVP.

    More Stories By Jon Box

    Jon Box is an Architect Evangelist in Developer & Platform Evangelism with the Microsoft Corporation. He coauthored Building Solutions with the Microsoft .NET Compact Framework, published by Addison-Wesley, and blogs at http://blogs.msdn.com/jonbox/default.aspx.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    @ThingsExpo Stories
    The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at Internet of @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, will discuss how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money! Speaker Bio: Esmeralda Swartz, CMO of MetraTech, has spent 16 years as a marketing, product management, and busin...
    Samsung VP Jacopo Lenzi, who headed the company's recent SmartThings acquisition under the auspices of Samsung's Open Innovaction Center (OIC), answered a few questions we had about the deal. This interview was in conjunction with our interview with SmartThings CEO Alex Hawkinson. IoT Journal: SmartThings was developed in an open, standards-agnostic platform, and will now be part of Samsung's Open Innovation Center. Can you elaborate on your commitment to keep the platform open? Jacopo Lenzi: Samsung recognizes that true, accelerated innovation cannot be driven from one source, but requires a...
    SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
    P2P RTC will impact the landscape of communications, shifting from traditional telephony style communications models to OTT (Over-The-Top) cloud assisted & PaaS (Platform as a Service) communication services. The P2P shift will impact many areas of our lives, from mobile communication, human interactive web services, RTC and telephony infrastructure, user federation, security and privacy implications, business costs, and scalability. In his session at Internet of @ThingsExpo, Robin Raymond, Chief Architect at Hookflash Inc., will walk through the shifting landscape of traditional telephone a...
    SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
    BSQUARE is a global leader of embedded software solutions. We enable smart connected systems at the device level and beyond that millions use every day and provide actionable data solutions for the growing Internet of Things (IoT) market. We empower our world-class customers with our products, services and solutions to achieve innovation and success. For more information, visit www.bsquare.com.
    How do APIs and IoT relate? The answer is not as simple as merely adding an API on top of a dumb device, but rather about understanding the architectural patterns for implementing an IoT fabric. There are typically two or three trends: Exposing the device to a management framework Exposing that management framework to a business centric logic • Exposing that business layer and data to end users. This last trend is the IoT stack, which involves a new shift in the separation of what stuff happens, where data lives and where the interface lies. For instance, it’s a mix of architectural style...
    SYS-CON Events announced today that SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
    From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.
    SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
    Connected devices are changing the way we go about our everyday life, from wearables to driverless cars, to smart grids and entire industries revolutionizing business opportunities through smart objects, capable of two-way communication. But what happens when objects are given an IP-address, and we rely on that connection, sometimes with our lives? How do we secure those vast data infrastructures and safe-keep the privacy of sensitive information? This session will outline how each and every connected device can uphold a core root of trust via a unique cryptographic signature – a “bir...
    Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
    Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
    WebRTC defines no default signaling protocol, causing fragmentation between WebRTC silos. SIP and XMPP provide possibilities, but come with considerable complexity and are not designed for use in a web environment. In his session at Internet of @ThingsExpo, Matthew Hodgson, technical co-founder of the Matrix.org, will discuss how Matrix is a new non-profit Open Source Project that defines both a new HTTP-based standard for VoIP & IM signaling and provides reference implementations.

    SUNNYVALE, Calif., Oct. 20, 2014 /PRNewswire/ -- Spansion Inc. (NYSE: CODE), a global leader in embedded systems, today added 96 new products to the Spansion® FM4 Family of flexible microcontrollers (MCUs). Based on the ARM® Cortex®-M4F core, the new MCUs boast a 200 MHz operating frequency and support a diverse set of on-chip peripherals for enhanced human machine interfaces (HMIs) and machine-to-machine (M2M) communications. The rich set of periphera...

    SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
    The Internet of Things (IoT) is going to require a new way of thinking and of developing software for speed, security and innovation. This requires IT leaders to balance business as usual while anticipating for the next market and technology trends. Cloud provides the right IT asset portfolio to help today’s IT leaders manage the old and prepare for the new. Today the cloud conversation is evolving from private and public to hybrid. This session will provide use cases and insights to reinforce the value of the network in helping organizations to maximize their company’s cloud experience.
    The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
    SYS-CON Events announced today that Matrix.org has been named “Silver Sponsor” of Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Matrix is an ambitious new open standard for open, distributed, real-time communication over IP. It defines a new approach for interoperable Instant Messaging and VoIP based on pragmatic HTTP APIs and WebRTC, and provides open source reference implementations to showcase and bootstrap the new standard. Our focus is on simplicity, security, and supporting the fullest feature set.
    Predicted by Gartner to add $1.9 trillion to the global economy by 2020, the Internet of Everything (IoE) is based on the idea that devices, systems and services will connect in simple, transparent ways, enabling seamless interactions among devices across brands and sectors. As this vision unfolds, it is clear that no single company can accomplish the level of interoperability required to support the horizontal aspects of the IoE. The AllSeen Alliance, announced in December 2013, was formed with the goal to advance IoE adoption and innovation in the connected home, healthcare, education, aut...