Class Requirements

  • All Implemented Interfaces:
    Parcelable

    public final class Requirements
    extends Object
    implements Parcelable
    Defines a set of device state requirements.
    • Field Detail

      • NETWORK

        public static final int NETWORK
        Requirement that the device has network connectivity.
        See Also:
        Constant Field Values
      • NETWORK_UNMETERED

        public static final int NETWORK_UNMETERED
        Requirement that the device has a network connection that is unmetered.
        See Also:
        Constant Field Values
      • DEVICE_IDLE

        public static final int DEVICE_IDLE
        Requirement that the device is idle.
        See Also:
        Constant Field Values
      • DEVICE_CHARGING

        public static final int DEVICE_CHARGING
        Requirement that the device is charging.
        See Also:
        Constant Field Values
      • DEVICE_STORAGE_NOT_LOW

        public static final int DEVICE_STORAGE_NOT_LOW
        Requirement that the device's internal storage is not low. Note that this requirement is not affected by the status of external storage.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Requirements

        public Requirements​(@RequirementFlags
                            int requirements)
        Parameters:
        requirements - A combination of requirement flags.
    • Method Detail

      • getRequirements

        @RequirementFlags
        public int getRequirements()
        Returns the requirements.
      • filterRequirements

        public Requirements filterRequirements​(int requirementsFilter)
        Filters the requirements, returning the subset that are enabled by the provided filter.
        Parameters:
        requirementsFilter - The enabled Requirements.RequirementFlags.
        Returns:
        The filtered requirements. If the filter does not cause a change in the requirements then this instance will be returned.
      • isNetworkRequired

        public boolean isNetworkRequired()
        Returns whether network connectivity is required.
      • isUnmeteredNetworkRequired

        public boolean isUnmeteredNetworkRequired()
        Returns whether un-metered network connectivity is required.
      • isChargingRequired

        public boolean isChargingRequired()
        Returns whether the device is required to be charging.
      • isIdleRequired

        public boolean isIdleRequired()
        Returns whether the device is required to be idle.
      • isStorageNotLowRequired

        public boolean isStorageNotLowRequired()
        Returns whether the device is required to not be low on internal storage.
      • checkRequirements

        public boolean checkRequirements​(Context context)
        Returns whether the requirements are met.
        Parameters:
        context - Any context.
        Returns:
        Whether the requirements are met.
      • getNotMetRequirements

        @RequirementFlags
        public int getNotMetRequirements​(Context context)
        Returns requirements that are not met, or 0.
        Parameters:
        context - Any context.
        Returns:
        The requirements that are not met, or 0.
      • equals

        public boolean equals​(@Nullable
                              Object o)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object