Android Device Emulator emulator

The Android Device Emulator enables you to emulate an Android handset. This gives you a way to deploy your Android application and test it before you release it to the market. In the previous section we ran our sample application using the emulator. It emulates all the features of the handset and provides a way to emulate various events. You can also invoke other applications and access various functionalities in the emulator.

You invoke the emulator by double-clicking it or by running the command emulator in the command prompt. You can also emulate events such as receiving an SMS or receiving a phone call.

To emulate these external events, telnet to the emulator and raise the necessary events. (Telnet is a command line utility that can be used to connect to remote system. In this instance we can use telnet to connect to the running emulator.) For example, to emulate an incoming call or receipt of an SMS, follow these steps:

1. Start the Android device emulator with the command emulator.

2. Open a command prompt and find out which port the emulator is running on by executing the command adb devices (see Figure 11.15).

FIGURE 11.15_

Output of the adb devices command.

3. Next, run the telnet localhost <port number> command and connect to the port. For example, in Figure 11.15, the emulator is using port 5554. So to use Telnet, you run the command telnet localhost 5554.

4. When you're connected, you can initiate an incoming call on the emulator by running the Telnet command gsm call <phone number> (see Figure 11.16).

CT L.rr-i-ni'id Fron-pi * mm ^B

, Eijat;

™1

Cr\Uaers\Prasanna>adb devices List of devices attached emulator-5554 device

1

|C: Mtsers\.Prasanna>

-

FIGURE 11.16_

Running a Telnet command to initiate an incoming call.

FIGURE 11.16_

Running a Telnet command to initiate an incoming call.

This simulates an incoming phone call from the phone number specified in the command, as shown in Figure 11.17.

FIGURE 11.17_

Incoming call on the emulator.

FIGURE 11.17_

Incoming call on the emulator.

5. If you want to initiate an SMS to the emulator, run the Telnet command sms <phone number> <message>.

0 0

Post a comment