我有2个关于Googles Awareness Fences API的问题:
答案 0 :(得分:1)
FenceStateMap
是否包含围栏密钥。以下是示例代码:
protected void queryFence(final String fenceKey) {
Awareness.FenceApi.queryFences(mGoogleApiClient,
FenceQueryRequest.forFences(Arrays.asList(fenceKey)))
.setResultCallback(new ResultCallback<FenceQueryResult>() {
@Override
public void onResult(@NonNull FenceQueryResult fenceQueryResult) {
if (!fenceQueryResult.getStatus().isSuccess()) {
Log.e(TAG, "Could not query fence: " + fenceKey);
return;
}
FenceStateMap map = fenceQueryResult.getFenceStateMap();
if (!map.getFenceKeys().contains(fenceKey)) {
// Fence is not registered.
}
}
});
}