androidgeolocationbroadcastreceiverandroid-geofence

Geofence Broadcast Receiver not triggered but when I open the google map, it works


I am developing an android app based on user location.

So I am using the "Geofence" enter/exit event.

It is not easy to test.

Because to test it, I should move out or in some location.

So I am using the emulator and set virtual location info (lat/lng).

Anyway, I found some info about this feature in here.

So I followed it, using broadcast receiver.

At the first time, It doesn't work. But, when I open "Google Map", my current location starting to change to what I set through the emulator.

And my broadcast receiver is triggered at that time.

But if I don't use "Google Map", nothing happen...

Why? and How can I handle this???


Solution

  • Actually, my app worked fine.

    But I added some new feature but it is not related with Geofence.

    After the update, geofence doesn't work.

    So I checked my commit list and I found something.

    I changed dependency library versions.

    I didn't find the root cause, but when I rollback the library version like below.

    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'androidx.core:core-ktx:1.2.0-alpha01'
    

    And now, Geofence works fine in background.