From 8cc378330f09da7f93ca221901496019774e87b8 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Mon, 20 May 2024 04:19:00 +0300 Subject: [PATCH] Attempt to workaround geofencing error Discussed here: https://stackoverflow.com/questions/78497339/geofence-bug-in-codename-one-on-android --- .../location/BackgroundLocationBroadcastReceiver.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Ports/Android/src/com/codename1/location/BackgroundLocationBroadcastReceiver.java b/Ports/Android/src/com/codename1/location/BackgroundLocationBroadcastReceiver.java index 9a7f063fe1..def4cc57b3 100644 --- a/Ports/Android/src/com/codename1/location/BackgroundLocationBroadcastReceiver.java +++ b/Ports/Android/src/com/codename1/location/BackgroundLocationBroadcastReceiver.java @@ -83,6 +83,12 @@ public void onReceive(Context context, Intent intent) { } if (ACTION_PROCESS_GEOFENCE_TRANSITIONS.equals(action)) { GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); + if(geofencingEvent == null) { + // Attempt to workaround this issue: https://stackoverflow.com/questions/78497339/geofence-bug-in-codename-one-on-android + Log.e(TAG, "Null geofencingEvent!"); + return; + } + if (geofencingEvent.hasError()) { String errorMessage = GeofenceStatusCodes .getStatusCodeString(geofencingEvent.getErrorCode());