Working with the Android emulator is not difficult. However we can still find ourselves at loss about doing some common stuffs with the emulator, like testing an SMS app etc. Here are a few how-tos with the Android emulator that explains how to accomplish a few basic stuffs (for a real device) with it.
How to send an SMS to the Android emulator.
So you are developing an SMS messaging app for android and don’t have a real device to test it or just want to test it on the emulator? No problem. “But how do I test if my app reacts properly to an incoming SMS?” Well, just send an SMS to your emulator and test it out. To send an SMS to the Android emulator, start your virtual device and open the DDMS perspective. On the DDMS perspective , look for something called the “Emulator Control” (usually at the left side of the DDMS view).
Provide a number in the incoming number box (this will be the number from which SMS was sent to the emulator). Once you have entered a number you will see the option buttons below it getting enabled. Click on the option button “SMS” and enter the SMS text in the Message box and click on send.
How to make a call
Basically, it’s the same process as sending an SMS. Instead of selecting the SMS option button, you should select the “Voice” option button and click on Call.
How to pull/push files to and from emulator virtual device?
A virtual device works exactly the same way as a real device sans some practical differences like sensors etc. This also means it saves files and data in a way similar to a real device. While developing an app your app may be saving data in files or may be using other files for various reasons. For any reason if you ever want to have a look at these files that are getting stored in the emulator virtual device, you need to pull that file to your computer and then view it.
First step to do this is to locate the file you want to pull and view. Open the DDMS perspective and click on the file explorer tab on top. Application data are usually stored in data/data/<package name>. So, if for example the package name of your app is com.myapp.mypackage and the file you are looking for is the sharepref.xml where you are saving your Preferences, you should probably look for the directory data/data/ com.myapp.mypackage/shared_prefs/ sharepref.xml . Now, once you have located your file, all you need to do is to select it and then click on the pull file from device icon in the top right corner. A save dialog would appear where you can specify the path to save the pulled file.
Similarly to push a file to the virtual device that is to copy a file from your computer to the virtual device, just browse to the folder where you want to place the file and click on the icon push a file onto device next to the pull file from device icon. A browse dialog would appear where you can browse for the file you want to push.
How to locate preferences file from a Virtual Device?
If for any reason you want to manually open and view the preferences file your app is using, use the same process of pulling a file and then viewing it. The preferences files would usually be located in the directory data/data/<package name>/shared_prefs/<your-preference-name>.xml
Want to take a screenshot of your android app running on the emulator? It’s super easy. If you look at the toolbar on the Devices tab on the DDMS perspective, you would see that there’s “Screenshot” icon on this toolbar. If you can’t see the icon, try clicking on the arrow icon at the end of the toolbar. All you need to do to take a screenshot is to click on this icon.