The objective of this article is to provide the prelude to the beginners of SmartPhone programming. This article provides introduction to SmartPhone, its features and APIs. Also, the article discusses on creating a simple program using C# for the SmartPhone.
In recent days, mobility is getting its momentum and attention both from the public consumers of mobile services and major corporations of the world. Mobility today equips knowledge workers with the power to access information and data from any part of the world.
As any other rapid technology evolution, mobility has certainly evolved and its recent form is on Mobile Phones, but be sure that, this mobility would create a whole new world and accessories useful for mankind, starting from a lay man to the richest. And it is also true that soon mobility would take another form and shape, and would become part of our lives.
Fine… But what do I get as a developer on all these happening around me… Actually, there is a whole new exciting world opened up for developers which is definitely a paradigm shift from today’s Desktop and Web Application development. New technology, new challenges, new opportunities, and… new way to earn… $ Money $ ;-)
As part of the evolution, we had various handheld devices, Pocket PCs, PDAs et al. Today’s mobility world is trying to gain advantage by leveraging advantages of successful cellular phones which are truly mobile and is owned by people of all sectors of the world.
There have been various models of phones available in today’s market. As of today, the market is ruled by Symbion OS embedded on the Nokia Phones and other proprietary phones like Sony, Samsung et al.
Much like the Web Browser market, Microsoft is a bit late to enter the mobile world. Today Microsoft has its own proprietary operation system, called as Microsoft Windows Mobile 2003, powered by the strong WinCE 4.2 OS. These phones with the Microsoft OS is slowly capturing up the market, and the developers' world.
As always, Microsoft provides adequate developer support to program these phones using existing languages and technologies. Microsoft .NET Compact Framework, a subset of the rich .NET Framework, does this magic. One great news is that the .NET CF runtime is now preloaded on the ROM of the Microsoft, which definitely eases the burden during the application deployment.
Microsoft SmartPhone is loaded with a very rich suite of software, which communicates to the user through Voice, Text and Internet capable applications, by leveraging the connectivity options like GSM, GPRS, SMS, PPTP, Bluetooth, USB, and Infrared IrDA.
Following is the comprehensive list of software usually loaded along with the Microsoft SmartPhone.
|Pocket Internet Explorer||No more plain vanilla WAP Browser on phones, instead a full blown IE 5 is loaded on the phones supporting HTML 3.2, XML, XSL, cHTML, WAP 1.2.1, WML Script, Active Script, ActiveX, SSL, JPEG, GIF etc.|
|Pocket Outlook||With tools for contacts, calendar, email, tasks and voice notes. Along with support for IMAP4, POP3 and SMS.|
|MSN Messenger||A full blown messenger|
|Microsoft ActiveSync||Supports Server and Desktop synchronization.|
|Windows Media Player||Plays MP3, WMA, AVI|
|Voice Notes||To quickly record voices|
|Games||Variety of Mobile games.|
|File Management Utilities||File Manager [like Windows Explorer], Task Manager|
|Wireless Modem||Options to connect through USB, IR, COM|
|MMS Client||Send and receive MMS messages|
|Camera||Camera support for image capture and video capture|
Microsoft has suggested a standard layout and control structure for the devices. [Ref: SmartPhone SDK]
The placement of soft keys, the Home key, the Back key, and the five-way navigation pad illustrated in the preceding figure is strongly recommended. All the hardware controls (soft keys, and so on) must be present; however, a device manufacturer is free to deviate from the design.
Recently, Microsoft launched the Microsoft Windows Mobile 2003 Second Edition, and the following developer tools are available, based on its open Win32 development environment and an SDK for SmartPhone [can be downloaded].
- Embedded VC++ 4.0
- Visual Studio .NET – C#, VB.NET
A Simple Hello World Program
Now, let’s get into business. Let us write a simple Hello World program. The first and foremost activity we need to do for programming the SmartPhone using Visual Studio 2003 is to download the SmartPhone 2003 SDK. Upon installing the SDK, the smart device extensions are extended with support for SmartPhone development along with the SmartPhone emulator.
After the SDK is installed, launch Visual Studio, choose Smart Device Application under project templates, and give a name for your application, and click OK. Now, you should see a screen as below:
Choose SmartPhone and Windows Application as depicted above, and hit the OK button. Now, you should see your favorite Visual Studio geared up for SmartPhone development.
On the Toolbox, you can see a list of controls, and some familiar controls are disabled, these disabled controls are not supported on the SmartPhone.
Now, we have to employ a goody good practice for SmartPhone development. We need to consider that the phones are usually operated using a single hand, therefore the navigability of the applications you create should be easy. The “Softkey” depicted on the layout plays a role here. If you closely observe VS, you might notice a default Menu control is created for you. It suggests you to use
MainMenu, which would become the default navigation keys to navigate your application using the soft keys of the mobile phone.
So, let us create a menu structure as below:
Double click on the “Say Hello”
MenuItem and write the following code:
private void menuItem2_Click(object sender,System.EventArgs e)
And write the following code for the Exit menu:
private void menuItem3_Click(object sender, System.EventArgs e)
Now, hit F5 to run the application, a new popup would request you choose the device to target, choose “Smartphone 2003 Emulator (Virtual Radio) (Default)”, and hit “Deploy”.
Now the emulator should load up, and the application would be deployed to the emulator, and a prompt would appear as below:
Click OK to continue to launch the application.
Now, your .NET application is loaded on the SmartPhone. After the application is launched, click “My Menu” and click “Say Hello”, you should see the alert message now… That’s it. Now, you can choose the target as SmartPhone device and deploy directly to your SmartPhone device also. Packaging and deployment is not discussed in this article as that would itself be another full article.
Following is the list of API's available for SmartPhone development:
- ActiveSync API
- Bluetooth API
- CE Messaging API
- Device Management API
- Home Screen API
- Object Exchange (OBEX)
- Pocket Outlook Object Model (POOM)
- Speech Recognizer
- Telephony - TAPI
- Accessing the SIM card
- P/Invoke to native SIM Toolkit APIs
- RAPI – Remote API to connect to the desktops programmatically
- GAPI – To develop Mobile games
- Vibrate API
- Voice Recorder Controls
Don't you think the SmartPhone is already powered up for today's Enterprise?
I strongly suggest you to read SmartPhone SDK documentation before diving into SmartPhone application development.
The world is not limited with this… but grows indefinitely.