Awareness API does not yet support creating fences based on Weather context.
As you have mentioned, you can create AwarenessFence for location and activity, and then combine them with AwarenessFence.and()
or AwarenessFence.or()
.
If you'd like weather to be included in your criteria for notifications, one thing you can do is to request the weather snapshot when you receive the fence callback on the intent, and then initiate notification if the weather matches your target conditions.
For example, borrowing directly from code snippets in the Awareness API guide,
public class MyFenceReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
FenceState fenceState = FenceState.extract(intent);
if (TextUtils.equals(fenceState.getFenceKey(), "headphoneFence")) {
switch(fenceState.getCurrentState()) {
case FenceState.TRUE:
WeatherResult weatherResult =
Awareness.SnapshotApi.getWeather(mClient).await();
if (weatherResult.getStatus().isSuccess()) {
Weather weather = weatherResult.getWeather();
if (myDesiredWeather(weather)) {
sendNotification();
}
}
break;
case FenceState.FALSE:
Log.i(TAG, "Headphones are NOT plugged in.");
break;
case FenceState.UNKNOWN:
Log.i(TAG, "The headphone fence is in an unknown state.");
break;
}
}
}
}
Admittedly this is a bit of a roundabout way of achieving what you want, but it seems the only way to solve your use-case.