BackgroundI have written a couple of posts before on Android Application development, debugging and other general concepts. As you know Android is just an operating system running on Linux kernel customized for resource constrained environment like that of handheld systems. Before you roll out your application to other users you need to test it on various models (with different configurations). This is where you Emulator comes into picture. You can create a emulator that suits your testing requirement. In this post we will cover some of the events that we can simulate with emulators like setting batter to low etc. So basically we will use a telnet to connect to Android virtual device and issue commands to simulate various events.
Creating an Android virtual Device
Lets start by creating an Android virtual device. Open your Eclipse which come as a pert of ADT bundle.
Windows -> Android Virtual Device Manager
I currently don't have any emulators. So the manager shows no emulators.
Go ahead and create one. Click on create button on the right. Fill in the configuration details as per your requirements.
After successful creation of AVD start it. Wait for it to initialize (It may take couple of minutes). My Emulator looks like the following at startup -
Now lets connect to it via telnet. See the number at the top of the Emulator ? (5554:athakur_Nexus) This number (5554) is the port number emulator is running on. You can do various action by connecting to it via telnet. Connecting is very simple. Simply type following in command prompt -
- telnet localhost 5554
- network speed edge
To change it back to 3G you can use command -
- network speed full
Lets first reduce the battery level. To do so you can use following command -
- power capacity 4
Battery is still charging. Notice the lightning symbol inside battery icon. Lets stop the charging. To do so use the following command -
- battery status not-charging (Usage: "status unknown|charging|discharging|not-charging|full")
- sms send 9999999999 "Hi! - From Open Source For Geeks" (Syntax : sms send <phonenumber> <text message>)
You can even change your coordinates on the map with following command -
- geo fix 2.00 39.12
These are only some command. To get a full list of command you can type help after connecting to telnet -
- You can reorient your device in the emulator by pressing Ctrl+F12 (Command+F12 on Mac). When this happens and your current Activity is killed and restarted.