Home Tutorials Hints & Tips

Using the Android Emulator to test Location Based Services

The Android emulator is a fantastic tool for testing many features within your apps. However, there are some sensors that it does not have. The GPS is one such sensor. That said, any developer would want to use the emulator to test location based services. This can be done by sending mock location data to the emulator in the form of longitude and latitude coordinates. There are a few things to bear in in mind to ensure that the emulator is able to handle the location data and , if not addressed, the emulator may not work as desired.

The more recent Android releases recommend that Google Play Services are used to deliver location based services with the FusedLocationProviderApi client. Google Play Services provides for better power management of the device by offering a balanced power options. A typical line of code is shown below and sets the balance between power consumption and accuracy.


This line of code is ideal for many apps whilst running on a real device. However, it simply will not work on the emulator. For emulator use you must use the highly accurate GPS. Therefore, change the line above to the one below whilst testing your app on the emulator.


There are a few more things to consider.

The target system image used for the emulator must be one that supports "Google APIs" as shown in the screen shot below.

Google API Traget System Image

Furthermore "Google Play Services" must be installed as part of the SDK. Check the SDK manager to ensure they are installed.

Google Play Services installed within Android SDK Manager

It is recommended that the ADB integration is tuned on. This will allow you to access the location data menu without running the device monitor.

Turn on Android ADB Integration

The location menu can then be access by selecting "extended controls" from the menu bar at the right hand side of the emulator.

Extended Controls for Location Based Services in Android Emulator

With all that done, you are good to go!

Privacy and Cookies Disclaimer Copyright
© 2015 - 2018 North Border Tech Training All rights reserved