Added Location Provider Changed Receiver to Reregister the geofences
parent
187d2bcd8b
commit
3392a2431b
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
|
||||||
|
package com.cloud.diplomaticquarterapp.geofence.intent_receivers
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.location.LocationManager
|
||||||
|
import android.util.Log
|
||||||
|
import com.cloud.diplomaticquarterapp.geofence.GeofenceTransition
|
||||||
|
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
|
||||||
|
import com.cloud.diplomaticquarterapp.geofence.PREFS_STORAGE
|
||||||
|
import com.cloud.diplomaticquarterapp.utils.HMGUtils
|
||||||
|
import com.cloud.diplomaticquarterapp.utils.saveLog
|
||||||
|
import com.google.android.gms.location.GeofencingEvent
|
||||||
|
|
||||||
|
class LocationProviderChangeReceiver : BroadcastReceiver() {
|
||||||
|
private val LOG_TAG = "LocationProviderChangeReceiver"
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
|
if (LocationManager.PROVIDERS_CHANGED_ACTION.equals(intent.action)) {
|
||||||
|
val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
|
||||||
|
pref.edit().putString("LOCATION_PROVIDER_CHANGE","YES").apply()
|
||||||
|
|
||||||
|
HMG_Geofence.shared(context).unRegisterAll { status, exception ->
|
||||||
|
val geoZones = HMGUtils.getGeoZonesFromPreference(context)
|
||||||
|
HMG_Geofence.shared(context).register(geoZones)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue