Class Download

  • public final class Download
    extends Object
    Represents state of a download.
    • Field Detail


        public static final int STATE_DOWNLOADING
        The download is currently started.
        See Also:
        Constant Field Values

        public static final int STATE_COMPLETED
        The download completed.
        See Also:
        Constant Field Values

        public static final int STATE_FAILED
        The download failed.
        See Also:
        Constant Field Values

        public static final int STATE_REMOVING
        The download is being removed.
        See Also:
        Constant Field Values

        public static final int STATE_RESTARTING
        The download will restart after all downloaded data is removed.
        See Also:
        Constant Field Values

        public static final int FAILURE_REASON_NONE
        The download isn't failed.
        See Also:
        Constant Field Values

        public static final int FAILURE_REASON_UNKNOWN
        The download is failed because of unknown reason.
        See Also:
        Constant Field Values

        public static final int STOP_REASON_NONE
        The download isn't stopped.
        See Also:
        Constant Field Values
      • state

        public final int state
        The state of the download.
      • startTimeMs

        public final long startTimeMs
        The first time when download entry is created.
      • updateTimeMs

        public final long updateTimeMs
        The last update time.
      • contentLength

        public final long contentLength
        The total size of the content in bytes, or C.LENGTH_UNSET if unknown.
      • stopReason

        public final int stopReason
        The reason the download is stopped, or STOP_REASON_NONE.
    • Method Detail

      • isTerminalState

        public boolean isTerminalState()
        Returns whether the download is completed or failed. These are terminal states.
      • getBytesDownloaded

        public long getBytesDownloaded()
        Returns the total number of downloaded bytes.
      • getPercentDownloaded

        public float getPercentDownloaded()
        Returns the estimated download percentage, or C.PERCENTAGE_UNSET if no estimate is available.