Geofence not triggering in background or when app is killed on Android 10+


I am implementing geofencing using Android Geofencing API.

Requirement

When a user enters an airport location, the app should trigger a notification — even if the app is in background or killed.

What I tried:

  1. Used GeofencingClient to register geofence

  2. Added required permissions:

    • ACCESS_FINE_LOCATION

    • ACCESS_BACKGROUND_LOCATION

  3. Tested on Android 12 device

Setup

  • GEOFENCE_TRANSITION_ENTER

  • INITIAL_TRIGGER_ENTER

  • BroadcastReceiver via PendingIntent

  • Radius ~2–3 km

  • Permissions:

    • ACCESS_FINE_LOCATION

    • ACCESS_BACKGROUND_LOCATION

Issue

  • ✅ Works when app is in foreground

  • ❌ Not triggering when:

    • app is in background

    • app is killed (swiped away)

BroadcastReceiver is not called in those cases.

Questions:

  1. Is this expected behavior on newer Android versions?

  2. Are there any restrictions that prevent geofencing from working when the app is killed?

  3. What is the recommended approach to reliably detect location entry (like airport detection) in background?

I am looking for a solution that works reliably on Android 10+ devices.

0
Apr 14 at 5:54 PM
User Avataruser30137923
#java#android#geofencing#android-geofence#geofence

No answer found for this question yet.