It seems almost all of the Apps I write these days are location aware in some regard. I’ve written here about the new iOS Simulator’s location setting and wanted to show the same for the Android Emulator.
There are several different ways to sent the emulator’s location information. Since I use a few different development environments I like to use Terminal since it let’s me keep the same workflow no matter the development platform.
Step 1: Platform Tools
Open Terminal and go to your AndroidSDK / platform-tools directory. Android let’s you call the directory you install the Android SDK into anything. For this example, I’m using the name AndroidSDK.
Step 2: Finding Attached Devices
The adb utility allows us to query all of the devices (and emulators) that are currently attached to the system. To do this we use the adb devices command as shown below.
After pressing enter you will see a list of all the devices linked to the system. In this case there is only the emulator shown below.
Step 3: Connect To Emulator
Using the information above we can telnet into the emulator using the below command.
This will connect you to the emulator as shown below.
This allows us to connect to the emulator directly and issue commands.
Step 4: Geo Fix A Location
Now we’ve connected to the emulator, we can use the geo fix command to set our location coordinates. The below example shows setting the coordinates for Time Square in New York City.
The format is:
You can read more about the different geo commands at the bottom of this page.
Video Walk Through
Here is a short video walk through of the above steps: