Android Things - Unable to get weather and location forecasts

I am trying to use the Google Awareness API in my IoT project, however when I call the weather and location API I get TIMEOUT errors.

Gradle:

compile 'com.google.android.gms:play-services-awareness:11.0.4' provided 'com.google.android.things:androidthings:0.5.1-devpreview'

manifest:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

API call:

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

The same code works fine on an Android device.

PS: The Internet works fine on my iot device, I have code that downloads the file as part of the project, and it works.

Do you have any idea what is going on?

+4
source share

Source: https://habr.com/ru/post/1686564/


All Articles