Google Awareness API无法在模拟器上注册围栏 [英] Google Awareness API cannot register fence on emulator

查看:246
本文介绍了Google Awareness API无法在模拟器上注册围栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下代码更新栅栏:

  AwarenessFence locationFence = LocationFence.entering(latitude,longitude,radius); 

Awareness.FenceApi.updateFences(
mGoogleApiClient,
新的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,护栏已成功注册);
}其他{
Log.e(标记,护栏无法注册:+状态);
}
}
});

它可以在物理设备上正常工作,但是在仿真器上我得到了以下logcat消息:

 状态{statusCode =未知状态码:7503,resolution = null} 

有没有人知道可能会导致这个问题的原因? 使用Awareness API,您需要:

GooglePlayServices(在模拟器上,Google Apis)



到位置Fences:位置服务在设备上激活。如果在仿真器或支架设备上,我认为你可以伪装它。



似乎活动检测感知使用了一组复杂的传感器,如加速度计,三角镜,位置等等。所以我现在不会在模拟器上有多高效。 / p>

最后,设备/模拟器需要Internet连接!乍一看,你可以认为Awareness location API是一个离线服务。 不是。如果您检查了您的Google开发者控制台,您可以看到Google服务器的提醒请求。



这个错误,由@jmols清楚地说明了这个故事:API试图访问连接意识服务的安全链,并失败。可能是因为该设备没有网络连接。



如果您的仿真器上有互联网连接,请仔细检查此API的凭据Google Developer Console。

I try to update fence using following code:

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);
                    }
                }
            });

It works fine on physical device, but on emulator I get following logcat message:

Status{statusCode=unknown status code: 7503, resolution=null}

Has anyone any idea what might cause this problem?

解决方案

To use the Awareness API, you need:

GooglePlayServices (on emulator, Google Apis)

To Location Fences: Location services activated on device. If on emulator or stand device, I think you can fake it.

Seems that activity detect awareness uses a complex bunch of sensors like accelerometer, giroscope, locations, etc. So I don't now how efficient that can be on emulator.

And, finally, the device/emulator needs Internet connection! At first glance, you can think that Awareness location API is an offline service. It's not. If you check your Google Developer Console, you can see the awareness requests to Google servers.

The error, kindly clarified by @jmols tell the tale: the API is trying access the security chain for connect with awareness service, and failing. Probably because the device doesn't have network connection.

If you have internet connection on your emulator, double check your credentials for this API on Google Developer console.

这篇关于Google Awareness API无法在模拟器上注册围栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆