我正在尝试在我的IoT项目中使用Google Awareness API,但是,在调用Weather和Location API时,我收到了TIMEOUT错误。
摇篮:
compile 'com.google.android.gms:play-services-awareness:11.0.4'
provided 'com.google.android.things:androidthings:0.5.1-devpreview'
清单:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
API调用:
Awareness.SnapshotApi.getWeather(mGoogleApiClient).setResultCallback(new ResultCallback<WeatherResult>() {
@Override
public void onResult(@NonNull WeatherResult weatherResult) {
Log.d(TAG, "Weather result received: " + weatherResult.getStatus());
Log.d(TAG, "Weather result code" + weatherResult.getStatus().getStatusCode());
Log.d(TAG, "Weather result message" + weatherResult.getStatus().getStatusMessage());
if (weatherResult.getStatus().isSuccess()) {
Weather weather = weatherResult.getWeather();
Log.d(TAG, "weather: " + weather);
int[] conditions = weather.getConditions();
}
}
});
logcat的:
09-28 16:10:37.557 3234-3234/com.iotunicamp.smartmirror D/DataProviderService: Weather result received: Status{statusCode=TIMEOUT, resolution=null}
09-28 16:10:37.558 3234-3234/com.iotunicamp.smartmirror D/DataProviderService: Weather result code 15
09-28 16:10:37.559 3234-3234/com.iotunicamp.smartmirror D/DataProviderService: Weather result message null
相同的代码在Android设备中正常运行。
PS:互联网在我的iot设备上工作正常,我有一个代码可以下载文件作为项目的一部分,它可以正常工作。
你知道发生了什么吗?