我正在开发一个基于用户位置的安卓应用.
I am developing an android app based on user location.
所以我正在使用地理围栏"进入/退出事件.
So I am using the "Geofence" enter/exit event.
测试并不容易.
因为要测试它,我应该搬出去或搬到某个地方.
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).
无论如何,我在 这里.
所以我跟着它,使用广播接收器.
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???
实际上,我的应用运行良好.
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 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.
这篇关于地理围栏广播接收器未触发,但当我打开谷歌地图时,它可以工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!