Geolocator

General

Category
Free
Tag
Location
License
MIT License
Min SDK
16 (Android 4.1 Jelly Bean)
Registered
Sep 7, 2019
Favorites
1
Link
https://github.com/exozet/Geolocator
See also
geo
GeoLocator-Android
GPSTracker
RxGeoFence
RxGps

Additional

Language
Kotlin
Version
N/A
Created
Sep 6, 2019
Updated
Sep 6, 2019
Owner
exozet
Contributors
Jan Rabe (kibotu)
Sprotte
2
Activity
Badge
Generate
Download
Source code

Advertising

Geofencer

How to install (tbd)

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
 repositories {
  ...
  maven { url 'https://dl.bintray.com/exozetag/maven' }
 }
}
Step 2. Add the dependency
dependencies {
 implementation 'com.sprotte:geofencer:latest'
}

Set up for geofence monitoring

The first step in requesting geofence monitoring is to request the necessary permission. To use geofencing, your app must request ACCESS_FINE_LOCATION. To request this permission, add the following element as a child element of the <manifest> element in your app manifest:

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

You have to inherit from GeofenceIntentService

class AppGeofenceService : GeofenceIntentService() {

    override fun onGeofence(geofence: Geofence) {
      //do your stuff like sendNotification(applicationContext, geofence.title, geofence.message)
    }
}

And register your service in the manifest

<service
 android:name=".ui.AppGeofenceService"
 android:permission="android.permission.BIND_JOB_SERVICE"
 android:exported="true"/>

Add your google key in strings.xml like so

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR_KEY</string>

How to use the library

val geofence = Geofence(id = "bla", latitude = 42.22, longitude = 57.234, radius = 10.0)
Geofencer(requireContext()).addGeofence(geofence, AppGeofenceService::class.java) {
 //success
}

Contributors

Jan Rabe

Paul Sprotte