I've just finished a codelab about WorkManager
and I was wondering how to get a "OR" condition with it. After checking the setRequiredNetworkType
I see it only accepts one argument of NetworkType
type.
/**
* Sets whether device should have a particular {@link NetworkType} for the
* {@link WorkRequest} to run. The default value is {@link NetworkType#NOT_REQUIRED}.
*
* @param networkType The type of network required for the work to run
* @return The current {@link Builder}
*/
public @NonNull Builder setRequiredNetworkType(@NonNull NetworkType networkType) {
this.mRequiredNetworkType = networkType;
return this;
}
For example, I'd like that my task runs when NetworkType.UNMETERED
or NetworkType.CONNECTED
. is it possible ?
EDIT: Maybe that wasn't a good example, I wanted to know if it's possible have an OR
condition to use for Constraint
.
CommonsWare answered my queestion in the comment:
"I wanted to know if it's possible have an OR condition to use for Constraint." -- not in a single piece of work. You might be able to rig up multiple pieces of work with separate constraints, and try some coordination such that only one will be used