New features provided by Windows Mobile 5.0 for developers (2)

Source: Internet
Author: User
Tags email account home screen
New features for developers in Windows Mobile 5.0 (2)

Message Processing

In addition to providing access to PIM data, the pocket outlook object model also uses the "Microsoft. windows Mobile. pocketoutlook. emailaccount and Microsoft. windows Mobile. pocketoutlook. the smsaccount namespace provides hosting support for email and SMS messages. Classes in these namespaces are managedCodeDevelopers can easily integrate message processing into their applicationsProgram.

For hosting application developers who need to integrate the email function,EmailaccountClass provides complete email functions, including support for attachments. The following code demonstrates how easily developers can send emails. This example usesChoosecontactdialogPrompt the user to select the contact to which the email is to be sent. Then, the Code creates an email, attaches a pocket Excel Workbook, and sends the email to the selected contact by using the main email account of the device.

Using Microsoft. windows Mobile. pocketoutlook; using Microsoft. windows Mobile. forms ;//... choosecontactdialogcontactdialog = new choosecontactdialog (); contactdialog. title = "Select User to send message"; if (contactdialog. showdialog () = dialogresult. OK) {emailmessage message = new emailmessage (); message. to. add (new recipient (contactdialog. selectedcontact. email1address); message. subject = "MEDC session List"; message. bodytext = "I 've attached the list of MEDC sessions-hope to see you there"; message. attachments. add (new attachment (@ "\ My Documents \ sessions.xls"); Using (outlooksessionsession = new outlooksession () {session. emailaccounts [0]. send (Message );}}

SMS is still a very popular and effective communication mechanism. Windows Mobile 5.0 hosting application developers can fully integrate the sending and receiving of SMS messages into their applications.

Use the following codeChoosecontactdialogPrompt the user to select a contact. Then, the code sends an email to the selected contact using the configured SMS account of the device, and then requests a receipt.

 using Microsoft. windows Mobile. pocketoutlook; using Microsoft. windows Mobile. forms ;//... choosecontactdialogcontactdialog = new choosecontactdialog (); contactdialog. title = "Select User to send message"; if (contactdialog. showdialog () = dialogresult. OK) {// construct message requesting delivery receept smsmessage message = new smsmessage (contactdialog. selectedcontact. moBi Letelephonenumber, "r u going to the keynote? "); Smsmessage message. requestdeliveryreport = true; // send message. Send () ;}

Windows Mobile 5.0 also makes it easy to intercept and process SMS messages. Developers can use "Microsoft. windows Mobile. pocketoutlook. messageinterception "namespace class (located in Microsoft. windows Mobile. pocketoutlook. NET Compact framework application to intercept and process the SMS messages sent to the device.

This information interception mechanism is highly configurable, so that applications can register Content-based interests in SMS information. Developers can program devices to send notifications about information to applications based on senders, receivers, or information content. Developers can also program the interception system so that it can be started when the application requesting notification is not yet running. Table 4 shows some information interception classes.

Table 4. Common SMS information interception and hosting classes
class description

messageinteceptor

an event is triggered when information that meets the specified conditions is reached. This class starts when the application requesting the notification is not running.

messagecondition

identifies information conditions to be met.

messageinteceptoreventhandler

Delegate types implemented by classes registered to receive information notifications.

Configuration Manager

Windows Mobile introduces the Configuration Manager, which greatly simplifies the configuration and deployment of Windows Mobile devices, because developers can set almost all configurable aspects of devices by using XML. UseMicrosoft. windowsmobile. configuration. configurationmanagerClass, managed developers can now make full use of this function.

ConfigurationmanagerThe class contains two static methods:ProcessconfigurationAndTestconfiguration. Hosted developers can useProcessconfigurationConfigure email, security policy, localization, home screen, virtual private network (VPN) settings, file system, and other settings. This class provides developers with an all-in-one solution to all device configuration problems.TestconfigurationThe managed developers can verify the validity of the configuration XML without affecting any device settings. The following example demonstrates how to useProcessconfigurationAdd the msdn mobility web site to your device browser favorites.

Using system. XML; using Microsoft. windows Mobile. configuration ;//... string configurationxml = @ "<WAP-provisioningdoc> <characteristic type = 'browserfavorite '> <characteristic type = 'msdnmobility'> <parm name = 'url' value = 'HTTP: // msdn.microsoft.com/equality'/> </characteristic> </WAP-provisioningdoc> "; // load xmlinto the DOM xmldocument configurationxmldoc = new xmldocument (); configurationxmldoc. loadxml (configurationxml); // send to Configuration Manager configurationmanager. processconfiguration (configurationxmldoc, false );

New additions that can be used by both local and hosted developersAPI

With the development of the Windows Mobile platform, more and more local and hosted developers are developing rich and complete applications. To meet the common needs of the two groups of developers, many new features of Windows Mobile 5.0 directly expose local and hosted APIs. This includes hosting APIs to make them part of the Windows Mobile 5.0 platform itself, so that these APIs are available to all hosted developers without considering the use of applications. the specific version of NET Compact framework.

State and notification broker API

Windows Mobile 5.0 introduces a very powerful tool called the state and notification broker API. The State and notification broker API provides a unified mechanism for storing device, application, and system status information. It is not only a Unified Storage, but also provides a centralized notification architecture so that applications can easily register notifications, you can start the application when the value you are interested in is changed. This model also allows applications to easily share their own state information.

Windows Mobile 5.0 devices come with more than 100 different status values, which can be obtained through the State and notification broker API. These available values provide a variety of information related to the device itself and the standard Windows Mobile 5.0 application. The following table is an example of information that can be obtained through State and notification BROKER:

Activity Application

ActiveSync status of the device

Current battery level

Whether a camera is connected to the device

Headset inserted?

Name of the currently played song in Media Player

Number of unread SMS messages

Number of unread emails

Is the current call in progress?

Whether a meeting call is ongoing

Can I use GPRS for connection?

Whether the device is connected to the VPN

Number of missed calls

The name of the mobile phone number.

Number of tasks scheduled for the current day

In addition to the preceding items, OEMs and application developers can expand the list. Developers can easily design applications to retrieve any State and notification broker API storage values, and, if necessary, developers can design applications to monitor changes to one or more values.

The basic implementation of state and notification broker depends on the registry. Each provider creates a registry key and adds a value to the entry to indicate the status values. After the provider creates this registry key, State and notification broker monitors changes to this value and automatically notifies all Parties that have registered an interest in this value. All system status attributes are stored inHKEY_CURRENT_USER \ System \ stateOrHKEY_LOCAL_MACHINE \ SYSTEM \ stateBelow. These items are protected to allow read-only access to untrusted applications. Applications can add their own status valuesHKEY_CURRENT_USER \ Software \ stateAndHKEY_LOCAL_MACHINE \ SOFTWARE \ state.

If local developers want to retrieve notifications, they have multiple options, including Windows messages, callback functions, and message queues. Developers who want to create notification providers can create an item under an appropriate registry location and useRegistrysetdwordOrRegistrysetstringFunction to create and modify the values under this item. Table 5 lists common local state and notification broker functions.

Table 5. Common State and notification broker API local functions
Function Description

Registrypolicyapp

Send a Windows message to the application window to notify the application of changes to the specified status value. If the application is not running, the state and notification broker API starts it.

Registrypolicywindow

Send a Windows message to the application window to notify the application of changes to the specified status value.

Registrypolicymsgqueue

By sending notifications to the named message queue, You can notify the application of changes to the specified status value.

Registrypolicycallback

Call the passed callback function to notify the application of changes to the specified status value.

Registrygetdword/registrygetstring

Retrieves the current status value.

Registrysetdword/registrysetstring

You can use the state and notification broker API provider to create and modify State values.

Registrytestexchangedword

The State and notification broker API provider is used to conditionally modify the state value, and tests and updates are executed as a single atomic operation.

A hosted developer interacts with state and notification broker by using a class that belongs to the "Microsoft. windowsmobile. Status" namespace and an assembly with the same name. The standard delegation mechanism is used to send status change notifications to managed classes. Table 6 lists common managed classes.

Table 6. Common State and notification broker API hosting classes
Function Description

Registrystate

Encapsulate the monitored Status values, including retrieval values, monitoring changes to the value, and starting the application as needed when the value is changed.

Systemstate

Provides abstraction over common system status values, and provides access to these values through attributes.

Image Selection dialog box

As applications increasingly merge photos and graphics, these applications need an easy way to present a list of images to users for users to choose from. To meet this requirement, Windows Mobile 5.0 provides an image selection dialog box. This dialog box is displayedGetfilenameexFunctions are provided to local developers. For hosted developersMicrosoft. windowsmobile. Forms. selectpicturedialogClass. Figure 2 shows the Image Selection dialog box.

Figure2.Image Selection dialog box. Click the thumbnail to view the large image.

The Image Selection dialog box is highly configurable, and application developers can control the dialog box behavior in multiple ways, this includes limiting the locations where users may browse images, controlling whether users are allowed to browse images from additional cameras (if any), and how to handleDRMProtected file.

Camera captureAPI/shcameracapture

Cameras are extremely popular. Because these devices are so widely used, as a result, application developers now have the opportunity to effectively enhance user experience by directly integrating static and video image capture into their applications. To enable application developers to easily provide this feature, Windows Mobile 5.0 provides a camera capture dialog box.

The camera capture dialog box provides a device-independent way for application developers to integrate capture of photos, videos, and audio-carrying videos into their applications. This dialog box provides developers with complete control over the camera capture process, including the capture type, quality, and maximum length (video only ). Local developers passShcamerac

Related Article

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.