How to install any application on the emulator

I’ve been developing an app recently that relies on being able to navigate and browse for images on the phone, which is all well and good when testing on a device as chances are you’ll have something like Astro installed.

This isn’t quite the case when developing on the emulator, since you’ll have just the stock version of android, which by default doesn’t come with a file browser (or at least not one you can easily interrogate).

The easiest thing to do, is just install a file browser (like Astro) onto the emulator….but wait…there is no market on the emulator so how do you do that?

Easy.

  1. You’ll need the applications APK file, the easiest way to do this is to just install it onto your device from the marketplace
  2. Connect your device to your development machine so that it is accessible via ddms.
  3. In ddms, go Device -> File Explorer
  4. Look under /data/app and search for the application you want to pull from the phone, then click the “pull from device” at the top left corner
  5. Save the apk somewhere
  6. Unplug your device, and start up the emulator
  7. Type adb devices and you should see just the emulator attached
  8. Now type adb install
  9. Voila! Your APK is now installed on the emulator, rinse and repeat for other applications

SMS text messaging simulation on android

As part of an application I’m currently developing, I need to be able to interogate incoming SMS messages. Since I’ll be developing against the emulator initially I need a way of sending in SMS messages to the emulator. Fortunately, we can use adb to poke in SMS messages at will, as detailed below.
Ultimately, you’ll need to telnet into your emulator, and you’ll need two things:
  • The port the emulator runs on. To find this out, open up a command window and type :

adb devices

You should see something like this :

C:\development\projects\AndroidSam\trunk_androidsam>adb devices
List of devices attached
emulator-5554 device
So my emulator is running on the default port of 5554.
  • Secondly, if you’re a Windows 7 / Vista user, you probably won’t have telnet enabled by default, so switch that on by going into Control Panel > Programs > Programs and Features > Turn Windows features on or off.

Now, lets actually send in an SMS. From the command window, type :

telnet localhost 5554

sms send 07841123123 Hello this is a sample message
OK

Then have a look at your emulator, you should see the SMS come through.
Stick around, I’ll post up some more SMS related tips in the coming weeks!