Awareness API always returning cloudy weather

2019-08-01 18:55发布

问题:

I want to be able to check the weather in my Android app. I implemented it, but it seems to always be returning conditions: [2] and nothing else, despite the fact it has been raining for almost an hour now here.

Here's what it's returning:

Temp=67.0F/19.444445C, Feels=67.0F/19.444445C, Dew=58.0F/14.444445C, Humidity=71, Condition=[2]

I'm testing this on Android v5.1 and yes fine location is in my manifest and turned on on my phone.

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

Here's my code for getting the weather:

Awareness.SnapshotApi.getWeather(mGoogleApiClient)
    .setResultCallback(new ResultCallback<WeatherResult>() {
        @Override
        public void onResult(@NonNull WeatherResult weatherResult) {
            if (!weatherResult.getStatus().isSuccess()) {
                System.out.println("error: /*- could not get weather");
                return;
            }
            weather = weatherResult.getWeather();
            System.out.println("weather: " + weather);
        }
    });

回答1:

Sorry to hear that your weather is terrible. Jokes aside, it might be a very local rainfall, while it is generally cloudy in the region since they get their weather data from some source, it might not be raining there. (Sometimes it rains in a 500m radius zone, but is sunshine all around it.

I thought something was weird as well at first, because it always reported the same temperature throughout my testing. Turned out the temperature just had been really stable, and the conditions worked fine for me, it called rain and some 15 minutes later it started raining outside my office.