Download
@UnstableApi
class Download
Represents state of a download.
Summary
Nested types |
|---|
@DocumentedFailure reasons. |
@DocumentedDownload states. |
Constants |
|
|---|---|
const Int |
The download isn't failed. |
const Int |
The download is failed because of unknown reason. |
const Int |
STATE_COMPLETED = 3The download completed. |
const Int |
The download is currently started. |
const Int |
STATE_FAILED = 4The download failed. |
const Int |
STATE_QUEUED = 0The download is waiting to be started. |
const Int |
STATE_REMOVING = 5The download is being removed. |
const Int |
STATE_RESTARTING = 7The download will restart after all downloaded data is removed. |
const Int |
STATE_STOPPED = 1The download is stopped for a specified |
const Int |
STOP_REASON_NONE = 0The download isn't stopped. |
Public constructors |
|---|
Download( |
Download( |
Public functions |
|
|---|---|
Long |
Returns the total number of downloaded bytes. |
Float |
Returns the estimated download percentage, or |
Boolean |
Returns whether the download is completed or failed. |
Public properties |
|
|---|---|
Long |
The total size of the content in bytes, or |
Int |
If |
DownloadRequest! |
The download request. |
Long |
The first time when download entry is created. |
Int |
The state of the download. |
Int |
The reason the download is stopped, or |
Long |
The last update time. |
Constants
FAILURE_REASON_UNKNOWN
const val FAILURE_REASON_UNKNOWN = 1: Int
The download is failed because of unknown reason.
STATE_QUEUED
const val STATE_QUEUED = 0: Int
The download is waiting to be started. A download may be queued because the
DownloadManager
- Is
DownloadManager#getDownloadsPaused() paused - Has
DownloadManager#getRequirements() Requirementsthat are not met - Has already started
DownloadManager#getMaxParallelDownloads() maxParallelDownloads
STATE_RESTARTING
const val STATE_RESTARTING = 7: Int
The download will restart after all downloaded data is removed.
Public constructors
Download
Download(
request: DownloadRequest!,
@Download.State state: Int,
startTimeMs: Long,
updateTimeMs: Long,
contentLength: Long,
stopReason: Int,
@Download.FailureReason failureReason: Int
)
Download
Download(
request: DownloadRequest!,
@Download.State state: Int,
startTimeMs: Long,
updateTimeMs: Long,
contentLength: Long,
stopReason: Int,
@Download.FailureReason failureReason: Int,
progress: DownloadProgress!
)
Public functions
getPercentDownloaded
fun getPercentDownloaded(): Float
Returns the estimated download percentage, or PERCENTAGE_UNSET if no estimate is available.
isTerminalState
fun isTerminalState(): Boolean
Returns whether the download is completed or failed. These are terminal states.
Public properties
contentLength
val contentLength: Long
The total size of the content in bytes, or LENGTH_UNSET if unknown.
failureReason
@Download.FailureReason
val failureReason: Int
If state is STATE_FAILED then this is the cause, otherwise FAILURE_REASON_NONE.