gpt4 book ai didi

Android Awareness API 多重围栏注册

转载 作者:行者123 更新时间:2023-11-29 01:10:13 25 4
gpt4 key购买 nike

我正在尝试在多个 session 中使用 Android 感知 API 注册多个位置围栏。但是每次我注册一个新的位置围栏时,它似乎会丢弃我的旧位置围栏并且不再触发它们。

String uniqueId = UUID.getid().toString() // sample to indicate this is always 
unique
AwarenessFence geoFence = LocationFence.in(lat, long, radius);
Awareness.FenceApi.updateFences(
googleApiClient,
new FenceUpdateRequest.Builder()
.addFence(uniqueId, geoFence, pendingIntent)
.build())
.setResultCallback(new ResultCallback () { .....});

我的待定意向:

Intent intent = new Intent(GeoBroadcastReceiver.BROADCAST_KEY);
Bundle bundle;
bundle = new Bundle();
bundle.putSerializable("model", model);
intent.putExtra("specialBundle", bundle);
PendingIntent geoBroadCastPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

The docs say this is how to add fences, but I wonder do i need to keep track of my old fences and anytime i use Awareness.FenceApi.updateFences, I need to add them in every-time?

最佳答案

我知道这是一个老问题,但我还是会回答,有人可能会觉得它有用。最近我遇到了类似的问题,我设法解决了。

在您的代码中,您将每个待定 Intent 设置为相同的 requestCode。因为那个和标志 FLAG_CANCEL_CURRENT 你覆盖了所有以前的未决 Intent (你总是设置为 0)。因此,要使其正常工作,您必须为每个笔划 Intent 设置唯一的 requestCode

关于Android Awareness API 多重围栏注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43702890/

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