I setup a geofence which gets triggered as expected, when the device exits the radius. However the geofencing event is completely empty.
override fun onReceive(context: Context, intent: Intent) {
val geofencingEvent = GeofencingEvent.fromIntent(intent)
}
Which is not very surprising, since the intent is empty as well. But where does e geofence-trigger intent usually get its data from to help GeofencingEvent.fromIntent() to build the event? What could go wrong, that the intent is empty? (no action, no extras... the intent uri looks like this :
intent:#Intent;launchFlags=0x10;component=de.yukiarts.test/.GeofenceBroadcastReceiver;end
I found this question from 7 years ago, which describes the same behavior without an answer. I followed this documentation pretty accuratley. Any ideas what I could be doing wrong?
I found out that making the PendingIntent which is used when the geofence is triggered mutable fixes this issue!(On Devices with Android >11)
val geofencePendingIntent = PendingIntent.getBroadcast(
context, 0, intent,
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT