Android Guides | Samples

Android.App.DownloadManager Class

The download manager is a system service that handles long-running HTTP downloads.

See Also: DownloadManager

Syntax

[Android.Runtime.Register("android/app/DownloadManager", DoNotGenerateAcw=true)]
public class DownloadManager : Object

Remarks

The download manager is a system service that handles long-running HTTP downloads. Clients may request that a URI be downloaded to a particular destination file. The download manager will conduct the download in the background, taking care of HTTP interactions and retrying downloads after failures or across connectivity changes and system reboots. Instances of this class should be obtained through Context.GetSystemService(String) by passing Context.DownloadService. Apps that request downloads through this API should register a broadcast receiver for DownloadManager.ActionNotificationClicked to appropriately handle when the user clicks on a running download in a notification or from the downloads UI. Note that the application must have the NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#INTERNET permission to use this class.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 9

The members of Android.App.DownloadManager are listed below.

See Also: Object

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
ActionDownloadCompleteString. Broadcast intent action sent by the download manager when a download completes.
const
ActionNotificationClickedString. Broadcast intent action sent by the download manager when the user clicks on a running download, either from a system notification or from the downloads UI.
const
ActionViewDownloadsString. Intent action to launch an activity to display all downloads.
const
ColumnBytesDownloadedSoFarString. Number of bytes download so far.
const
ColumnDescriptionString. The client-supplied description of this download.
const
ColumnIdString. An identifier for a particular download, unique across the system.
const
ColumnLastModifiedTimestampString. Timestamp when the download was last modified, in JavaSystem.CurrentTimeMillis (wall clock time in UTC).
const
ColumnLocalFilenameString. The pathname of the file where the download is stored.
const
ColumnLocalUriString. Uri where downloaded file will be stored.
const
ColumnMediaproviderUriString. The URI to the corresponding entry in MediaProvider for this downloaded entry.
const
ColumnMediaTypeString. Internet Media Type of the downloaded file.
const
ColumnReasonString. Provides more detail on the status of the download.
const
ColumnStatusString. Current status of the download, as one of the STATUS_* constants.
const
ColumnTitleString. The client-supplied title for this download.
const
ColumnTotalSizeBytesString. Total size of the download in bytes.
const
ColumnUriString. URI to be downloaded.
const
ErrorCannotResumeDownloadError (1008). Value of DownloadManager.ColumnReason when some possibly transient error occurred but we can't resume the download.
const
ErrorDeviceNotFoundDownloadError (1007). Value of DownloadManager.ColumnReason when no external storage device was found.
const
ErrorFileAlreadyExistsDownloadError (1009). Value of DownloadManager.ColumnReason when the requested destination file already exists (the download manager will not overwrite an existing file).
const
ErrorFileErrorDownloadError (1001). Value of DownloadManager.ColumnReason when a storage issue arises which doesn't fit under any other error code.
const
ErrorHttpDataErrorDownloadError (1004). Value of DownloadManager.ColumnReason when an error receiving or processing data occurred at the HTTP level.
const
ErrorInsufficientSpaceDownloadError (1006). Value of DownloadManager.ColumnReason when there was insufficient storage space.
const
ErrorTooManyRedirectsDownloadError (1005). Value of DownloadManager.ColumnReason when there were too many redirects.
const
ErrorUnhandledHttpCodeDownloadError (1002). Value of DownloadManager.ColumnReason when an HTTP code was received that download manager can't handle.
const
ErrorUnknownDownloadError (1000). Value of COLUMN_ERROR_CODE when the download has completed with an error that doesn't fit under any other error code.
const
ExtraDownloadIdString. Intent extra included with DownloadManager.ActionDownloadComplete intents, indicating the ID (as a long) of the download that just completed.
const
ExtraNotificationClickDownloadIdsString. When clicks on multiple notifications are received, the following provides an array of download ids corresponding to the download notification that was clicked.
const
IntentExtrasSortBySizeString. Intent extra included with DownloadManager.ActionViewDownloads to start DownloadApp in sort-by-size mode.
const
PausedQueuedForWifiDownloadPausedReason (3). Value of DownloadManager.ColumnReason when the download exceeds a size limit for downloads over the mobile network and the download manager is waiting for a Wi-Fi connection to proceed.
const
PausedUnknownDownloadPausedReason (4). Value of DownloadManager.ColumnReason when the download is paused for some other reason.
const
PausedWaitingForNetworkDownloadPausedReason (2). Value of DownloadManager.ColumnReason when the download is waiting for network connectivity to proceed.
const
PausedWaitingToRetryDownloadPausedReason (1). Value of DownloadManager.ColumnReason when the download is paused because some network error occurred and the download manager is waiting before retrying the request.
const
StatusFailedDownloadStatus (16). Value of DownloadManager.ColumnStatus when the download has failed (and will not be retried).
const
StatusPausedDownloadStatus (4). Value of DownloadManager.ColumnStatus when the download is waiting to retry or resume.
const
StatusPendingDownloadStatus (1). Value of DownloadManager.ColumnStatus when the download is waiting to start.
const
StatusRunningDownloadStatus (2). Value of DownloadManager.ColumnStatus when the download is currently running.
const
StatusSuccessfulDownloadStatus (8). Value of DownloadManager.ColumnStatus when the download has successfully completed.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddCompletedDownload(String, String, Boolean, String, String, Int64, Boolean) : Int64
Adds a file to the downloads database system, so it could appear in Downloads App (and thus become eligible for management by the Downloads App).
Enqueue(DownloadManager+Request) : Int64
Enqueue a new download.
static
FromContext(Context) : DownloadManager
static
GetMaxBytesOverMobile(Context) : Long
Returns maximum size, in bytes, of downloads that may go over a mobile connection; or null if there's no limit
GetMimeTypeForDownloadedFile(Int64) : String
Returns the media type of the given downloaded file id, if the file was downloaded successfully.
static
GetRecommendedMaxBytesOverMobile(Context) : Long
Returns recommended maximum size, in bytes, of downloads that may go over a mobile connection; or null if there's no recommended limit.
GetUriForDownloadedFile(Int64) : Uri
Returns the Uri of the given downloaded file id, if the file is downloaded successfully.
InvokeQuery(DownloadManager+Query) : ICursor
Query the download manager about downloads that have been requested.
OpenDownloadedFile(Int64) : ParcelFileDescriptor
Open a downloaded file for reading.
Remove(params Int64[]) : Int32