Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to spoof location to do testing with LocationClient and Geofences on Android?

I've been working with the LocationClient and have setup a Geofence, but don't know how to test it.

The issue comes from the fact that you can't run the app in an emulator, because LocationClient uses GooglePlayServices which are unavailable in an emulator. You also can't use MockLocations as far as I know, because you use MockLocations by creating a Provider, and LocationClient doesn't let you set a Provider.

So... how am I supposed to test my Geofence? (Besides getting in the car...).

like image 467
Greyson Parrelli Avatar asked Oct 04 '22 20:10

Greyson Parrelli


1 Answers

Most phones have a debug setting to enable mocking the location.

For example on my Samsung S3 it's under

Settings->Developer options->Allow mock locations

After turning this on you need an app from the play store that sets the location.

As an example https://play.google.com/store/apps/details?id=com.lexa.fakegps&hl=en

like image 51
Lionel Port Avatar answered Oct 07 '22 03:10

Lionel Port