Network Access within the Emulator
One of the most commonly performed tasks in a Windows Mobile application is network access. For example, your Windows Mobile application may connect to a web service, so you need Internet access in order to test this feature. Fortunately, the latest version of the device emulator makes it easy to connect to the Internet via the following ways:
- Network card mapping
The first way to get connectivity in the emulator is to cradle the emulator to ActiveSync and use ActiveSync toconnect to the Internet.
First, you need to prepare ActiveSync. In ActiveSync, go to File>Connection Settings…. Check the Allow connections to one of the following checkbox and select the DMA option. Click OK. To cradle an emulator to ActiveSync, right-click on the emulator in the Device Emulator Manager and select Cradle. When the emulator is successfully cradled to ActiveSync, its icon will change accordingly--and so will the icon on the Home screen.
The emulator will now connect to ActiveSync and you will be brought through a series of steps to synchronize the emulator with ActiveSync. If your sole intention is to allow the emulator to access the network, click Cancel. Clicking the emulator's icon will display that ActiveSync is connected (see Figure 6).
Figure 6. Click the Icon: This verifies that ActiveSync is connected.
Figure 7. Using the Network Card: Mapping the network adapter in the emulator to the PC's network card.
The second way to connect your emulator to the network is to enable the NE2000 PCMCIA network adapter in the emulator and bind it to the network card on your computer. To use this option, go to the File>Settings option in the emulator, click on the Network tab, check the Enable NE2000 PCMCIA network adapter, and bind it to the checkbox (see Figure 7). Select the Connected network card option and click OK.
In order to use this option, you'll need to install Virtual PC 2007. Download a free copy here.
Once the network card is successfully mapped, click on the network icon in the Home screen. This should show that the Network Card is connected.
The third way to connect is to emulate a GPRS connection on the emulator. In order to use this option, you need to use the Cellular Emulator (the next section shows how you use the Cellular Emulator with your Windows Mobile emulator).
Once the Cellular Emulator is up and running, click the Start>Settings options within the Windows Mobile emulator. Select the Connections tab and click the Connections icon. You will see the Connections screen. Click the Add a new modem connection link (under the My ISP) section. In the next screen, give a name to the connection and select Cellular Line (GPRS).
Click Next and leave the Access point name blank. In the next screen, leave out the User name, Password, and Domain and click Finish.
Now, you can test to see if the connection works. Launch Pocket Internet Explorer and try to navigate to a site. You will see the "G" icon located at the top of the Windows Mobile emulator. At the same time, in the Cellular Emulator you will also see the number of bytes transferred listed in the Network tab (see Figure 8).
Figure 8. Downloading Data: The Cellular Emulator displays the network statistics as the Windows Mobile emulator downloads data.
Figure 9. Emulate 3G: Click the Switch to 3G button in the Cellular Emulator.
You can also emulate a 3G connection by clicking on the Switch to 3G button in the Cellular Emulator (see Figure 9).