I register my broadcast receiver once (debugged it), but onReceive() gets triggered 4 times.
private val locationBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (LocationManager.PROVIDERS_CHANGED_ACTION == intent.action) {
val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val locationEnabled = isLocationEnabled(locationManager)
//..
}
}
}
Is there clean way of making sure that receiver gets triggered once on every user action? (GPS toogle on/off in this case)