Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing geofencing with Google Play Services 6.5.+

I've been testing the geofencing api available in the latest Google Play Services, using the official sample available here: https://github.com/googlesamples/android-Geofencing/ And of course, following the training course: http://developer.android.com/training/location/geofencing.html

The sample displays a notification when you are nearing two Google buildings in San Fransisco, so I tweaked it to be triggered when I'm nearing my home or my work place.

If I use a real device, it works. The notifications are triggered properly. But when I'm using a simulator, and change the location with telnet or ddms, nothing happens. I also tried with Genymotion, with the Gapps installed, and same stuff: nothing.

Would anyone have any pointer about how to test geofence, without actually moving my butt? Because in the street, there is no way to debug the code...

like image 569
Redwarp Avatar asked Mar 13 '15 10:03

Redwarp


People also ask

How do I use Google geofencing?

To do so, choose a campaign and then go to its Settings page. You can choose from a number of geo-targeting options such as Country, State, Zip Code, Radius and City. You can set up geofencing on the ads displayed on google search results, the display network and YouTube.

Can you use geofencing without an app?

An app – very important to note that geofences for 99,9% of the use cases cannot be used without an app. There are some minor exceptions, but most likely, if you are reading this blog post, you will need an application – whether your own or through a partner – that can be utilized for this purpose.


2 Answers

Here is what you need to do:

  1. Settings -> Developer options -> Allow mock locations

  2. Add the following permission:

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

  1. Ensure your GPS location service is ON (high accuracy) not Network location

  2. Download an app called Fake GPS (it has yellow happy fact holding a remote control) from the app store. You can set your fake GPS using that app

Hope this answers you question :)

like image 70
Snake Avatar answered Sep 30 '22 12:09

Snake


I had the same issue, if you have a device you can easily fake the location by enabling mocking location in the settings

Settings-> Developer options-> Allow mock locations

And you also have to add this in the manifest:

 <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />  

I never tried on the emulator, but try to open the emulator and do the same things (go to settings and enable mock locations), good luck!

like image 35
Sid Avatar answered Sep 30 '22 11:09

Sid