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...
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.
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.
Here is what you need to do:
Settings -> Developer options -> Allow mock locations
Add the following permission:
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
Ensure your GPS location service is ON (high accuracy) not Network location
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 :)
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With