![](/img/trans.png)
[英]Google Awareness API cannot register location fence (Fence API) Kotlin
[英]Google Awareness API cannot register fence on emulator
我尝试使用以下代码更新篱笆:
AwarenessFence locationFence = LocationFence.entering(latitude, longitude, radius);
Awareness.FenceApi.updateFences(
mGoogleApiClient,
new FenceUpdateRequest.Builder()
.addFence(LOCATION_FENCE_KEY, locationFence, mPendingIntent)
.build())
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Fence was successfully registered.");
} else {
Log.e(TAG, "Fence could not be registered: " + status);
}
}
});
它在物理设备上工作正常,但是在仿真器上,我收到以下logcat消息:
Status{statusCode=unknown status code: 7503, resolution=null}
有谁知道什么可能导致此问题?
您是否尝试过在模拟器中设置位置? 此页面上有说明:
根据文档, 7503表示 :
ACL_ACCESS_DENIED:ACL身份验证失败。
但是,这似乎是模拟器问题,因为注册TimeFence
确实对我TimeFence
。 而位置围栏和活动围栏则没有。
AwarenessFence timeFence = TimeFence.inSaturdayInterval(TimeZone.getDefault(), 0, 24 * 60 * 60 * 1000);
要使用Awareness API,您需要:
GooglePlayServices(在模拟器上为Google Apis)
到位置围栏:在设备上激活了位置服务。 如果在模拟器或站立设备上,我认为您可以伪造它。
似乎活动检测意识使用了一系列复杂的传感器,例如加速度计,陀螺仪,位置等。因此,我现在不了解模拟器的效率如何。
最后,设备/仿真器需要Internet连接! 乍一看,您可以认为Awareness location API是一种离线服务。 不是 。 如果您检查自己的Google Developer Console,则可以看到对Google服务器的感知请求。
错误由@jmols清楚地说明了:API正在尝试访问安全链以与感知服务建立连接,但失败了。 可能是因为该设备没有网络连接。
如果您的仿真器具有互联网连接,请在Google Developer控制台上仔细检查此API的凭据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.