問題描述
我正在開發一個基于用戶位置的安卓應用.
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模板網!