Tuesday 28 January 2014

Groking The Android Emulator

The Android SDK offers a bunch of mouth-watering tools to developers to increase their productivity. Most of these tools are second-to-non when compared to the tools provided by other rival mobile platforms such as Apples iOS (XCode).

One of the most outstanding tools in the Android SDK is the Android Virtual Device, A.K.A Emulator. In this post, am gonna show you how to have fun with the Android Emulator. I assume you already have your SDK setup and some ADVs created.

Now run an instance of the emulators shown in your AVD Manager.
Each instance of the emulator is bound to a port number which is shown on the title bar of the emulator window. My emulator's port number as at the time of this post shows 5554. (Yours may be different anyway)

Now, let's connect to the running emulator via telnet.
Open your terminal or command prompt and execute the following command

telnet localhost 5554 (Replace 5554 with the port number shown on your emulator)

If everything goes as planned you should see an output similar to

Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK

If you've got this output in your terminal just jump and shout hurraaaay! (watch out for the ceiling fan)

Now all is set to grok the emulator

1. Let's change the network status from 3G to Edge and back
Type
network speed edge
Observe your emulator's signal indicator changing to show edge
Now type
network speed 3g
Observe your emulator's signal indicator changing to show 3G

(Wait! Wait!!, don't jump yet)

2.Let's simulate an incoming sms
Type 
sms send 0200662782 "Howdy?, Mr Spanky emulator" (Change the phone number)
Observe your emulator's notification bar as your girlfriend drops in a new romantic message
Mind you, this isn't a replacement for WhatsApp, Lol!

3.Let's simulate a low-battery environment
Type
power capacity 4
Observe your battery indicator drop to 4%
Don't keep doing this cos you don't know when ECG will get you a real low-battery situation.

NOTE :
There are tonnes of command you should know of. Apply whatever you've learnt here to simulate such situation when needed to test your apps in the emulator.
Want to be a groking monster? Point your browser here.

May 2014 kick 2013's flat ass!!!

3 comments: