Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Geofence helper library for Android - No longer maintained, see my JCVD lib for replacement

License

Notifications You must be signed in to change notification settings

djavan-bertrand/GeofenceHelper

Repository files navigation

Release Build Status

GeofenceHelper

This library helps you to use the geofencing on Android.

It stores your geofences, add them to the Google API and informs the caller about the status of the operation.

An example is also provided. It shows you how to create, add and delete a geofence.

The status of this library is currently in beta.

Import the library to your project

First add the Jitpack repository to your project build.gradle file:

repositories {
    // ...
    maven { url "https://jitpack.io" }
}

Then add the dependency to the GeofenceHelper library in the build.gradle.

dependencies {
    // ...
    compile 'com.github.djavan-bertrand:GeofenceHelper:0.0.3'
}

Adding this dependency will also add the following permissions to your apk:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

How to use

A working example is available in the project.

Here are the main points:

Declare a StorableGeofenceManager.

private StorableGeofenceManager mGeofenceManager;

Then create it and declare your class as a listener

mGeofenceManager = new StorableGeofenceManager(this);
mGeofenceManager.setListener(this);

Add a geofence

StorableGeofence storableGeofence = new StorableGeofence(
                geoId,
                receiverClassName,
                latitude,
                longitude,
                radius,
                Geofence.NEVER_EXPIRE,
                Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT,
                additionalData);
boolean addedOnGoing = mGeofenceManager.addGeofence(storableGeofence);

receiverClassName is the name of the class that will be called when the geofence is triggered by Android. It should inherits from IntentService.
additionalData is an HashMap<String, Object> which provides additional data. The values should be of the following types: String, Long, Integer, Double Boolean or Float.

addedOnGoing is the immediate result of the call. It is true if add has been asked, false otherwise.

After this call, if addedOnGoing is true, the geofenceAddStatus callback will be called to inform you about the status of the Geofence.

Questions

Feel free to ask your questions to @Djava7.
You can also open an issue on Github.

About

Geofence helper library for Android - No longer maintained, see my JCVD lib for replacement

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages