RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Cool New Tools in Windows Mobile 6 : Page 3

While it may be some time before you can get your hands on a Windows Mobile 6 device, this early look at the Windows Mobile 6 SDK reveals some of the new tools and utilities you'll be using soon.

Device Emulator v2
The Windows Mobile 6 SDK's emulators are now much more realistic and offer significantly improved performance. You can now also emulate different battery power levels, as well as speakerphone, headset, and car kit (see Figure 3).

Figure 3. Emulating Different Peripherals: Battery power levels, speakerphone, headset, and car kit.

For example, suppose your application wants to monitor the battery power status and issue a warning when the battery power is low. You can do the following:

Imports Microsoft.WindowsMobile
Imports Microsoft.WindowsMobile.Status

Public Class Form1
    Private WithEvents batteryState As Status.SystemState

    Private Sub Form1_Load( _
       ByVal sender As System.Object, _
       ByVal e As System.EventArgs) _
       Handles MyBase.Load
        batteryState = New Status.SystemState( _
    End Sub

    Private Sub batteryState_Changed( _
       ByVal sender As Object, _
       ByVal args As Microsoft.WindowsMobile.Status.ChangeEventArgs) _
       Handles batteryState.Changed
        If SystemState.PowerBatteryStrength = BatteryLevel.Low Or _
           SystemState.PowerBatteryStrength = BatteryLevel.VeryLow Then
            MsgBox("Please remember to save your work.")
        End If
    End Sub
End Class
In this case, you can adjust the battery power level of a device and see how your code reacts to it. The battery level in Figure 3 is adjusted to 5 percent. Figure 4 shows the Main Battery Very Low notification message and the message displayed by your code (on the right).

Figure 4. Emulating Low-battery Status: The message displayed by your code is on the right.

Cellular Emulator v1
One very useful tool in the Windows Mobile 6 SDKs is the Cellular Emulator. The Cellular Emulator emulates real phone functionalities such as voice calls and SMS messaging. To use the Cellular Emulator with your Windows Mobile emulator, launch it from Start | Windows Mobile 6 SDK | Tools | Cellular Emulator and observe the serial port number it uses (see Figure 10). In this case, the port is COM3.

Next, open up the Emulator Properties window by going to File | Configure… and enter the port number (COM3) under Serial Port 0.

Using the Windows Mobile emulator, you can emulate making a phone call by calling one of the pre-fixed numbers (Figure 5):

  • 7272024 - Busy
  • 7272020 - Reject
  • 7272021 – Hang Up after Connect
  • 7272022 – No answer

You can also use the Cellular Emulator to make calls to the Windows Mobile emulator, as shown in Figure 6.

Figure 5. The Emulator: Making a phone call.
Figure 6. The Cellular Emulator: Use it to make calls to the emulator.

For network emulation, the Cellular Emulator allows you to emulate 2G and 3G networks (see Figure 7).

For SMS messaging, you can send a message from the Windows Mobile emulator and if the message is sent correctly, the Cellular Emulator will receive it (see Figure 8).

Figure 7. The Cellular Emulator: Emulating 2G and 3G networks.
Figure 8. Sending an SMS Message: From the Windows Mobile emulator to the Cellular Emulator.

Conversely, you can also send a SMS message from the Cellular Emulator to the Windows Mobile emulator (see Figure 9).

Figure 9. Sending an SMS Message: From the Cellular emulator to the Windows Mobile emulator.
Figure 10. SMS Series: Sending a series of SMS messages at regular time intervals.

The ability to send SMS messages using the Cellular Emulator is very useful—especially if you are writing SMS applications and need to filter incoming messages. For example, the following code snippet will intercept all incoming messages, pass them to your application for processing (in this case display the content of the message on the screen), and delete them:

Imports Microsoft.WindowsMobile.PocketOutlook.MessageInterception
'---add reference to Microsoft.WindowsMobile.PocketOutlook---

Public Class Form1
    Dim msgInterceptor As MessageInterceptor
    Private Sub Form1_Load( _
       ByVal sender As System.Object, _
       ByVal e As System.EventArgs) _
       Handles MyBase.Load

        msgInterceptor = New MessageInterceptor( _
           InterceptionAction.NotifyAndDelete, True)

        '---set the event handler for the message interceptor
        AddHandler msgInterceptor.MessageReceived, _
           AddressOf smsInterceptor_MessageReceived
    End Sub

    '---event handler for the MessageReceived event
    Private Sub smsInterceptor_MessageReceived( _
       ByVal sender As Object, _
       ByVal e As MessageInterceptorEventArgs)

        Dim msg As Microsoft.WindowsMobile.PocketOutlook.SmsMessage
        msg = e.Message
    End Sub

End Class
You can also configure the Cellular Emulator to continuously send SMS messages to the Windows Mobile emulator at regular time intervals (Figure 10).

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date