作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在多个 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/
我是一名优秀的程序员,十分优秀!