gpt4 book ai didi

java - GeotriggerHandlerReceiver 在 PlotProjects 中被弃用。什么是替代使用?

转载 作者:行者123 更新时间:2023-11-30 00:15:44 24 4
gpt4 key购买 nike

我在 Plot Project 的文档中看到应该使用 GeotriggerHandlerReceiver,但根据 Android Studio 的版本 com.plotprojects:plot-android:2.4.0-beta,此 Receiver 已被弃用。

Image from Android Studio

3.5 Geotrigger handler When you want to handle your geotriggers, or use them as trigger events for your own code, you can use the geotrigger handler. Plot automatically detects whether a service is registered in AndroidManifest.xml that extends from the class GeotriggerHandlerReceiver. Implementations of GeotriggerHandlerReceiver must implement the method public List handleGeotriggers(List geotriggers). When the service is defined, Plot will send the geotriggers to this method before considering them as handled. This allows you to add custom code that is triggered by entering (or exiting) a geofence or beacon region.

//Example implementation for handleGeotriggers:
public class MyGeotriggerHandlerReceiver extends GeotriggerHandlerReceiver {
@Override
public List<Geotrigger> handleGeotriggers(List<Geotrigger> geotriggers) {
List<Geotrigger> passedGeotriggers = new ArrayList<Geotrigger>();
for (Geotrigger geotrigger : geotriggers) {
String data = geotrigger.getData();
if (data.equals("pass")) {
passedGeotriggers.add(geotrigger);
}
}
return passedGeotriggers;
}
}

最佳答案

事实上,我们正在弃用 GeotriggerHandlerReceiver 并将在下一个版本中将其删除。为了使您的代码保持最新,请遵循此 guide .该指南解释了为什么以及如何执行此操作。

我们正在更新我们的文档,以使其更有条理和完整。

干杯!

关于java - GeotriggerHandlerReceiver 在 PlotProjects 中被弃用。什么是替代使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47335056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com