地理围栏广播接收器未触发,但当我打开谷歌地

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.

测试并不容易.

因为要测试它,我应该搬出去或搬到某个地方.

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.

这篇关于地理围栏广播接收器未触发,但当我打开谷歌地图时,它可以工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)