/**@class android.app.DownloadManager @extends java.lang.Object 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. <p> Apps that request downloads through this API should register a broadcast receiver for {@link #ACTION_NOTIFICATION_CLICKED} to appropriately handle when the user clicks on a running download in a notification or from the downloads UI. <p> Note that the application must have the {@link android.Manifest.permission#INTERNET} permission to use this class. */ var DownloadManager = { /** An identifier for a particular download, unique across the system. Clients use this ID to make subsequent calls related to the download. */ COLUMN_ID : "_id", /** The client-supplied title for this download. This will be displayed in system notifications. Defaults to the empty string. */ COLUMN_TITLE : "title", /** The client-supplied description of this download. This will be displayed in system notifications. Defaults to the empty string. */ COLUMN_DESCRIPTION : "description", /** URI to be downloaded. */ COLUMN_URI : "uri", /** Internet Media Type of the downloaded file. If no value is provided upon creation, this will initially be null and will be filled in based on the server's response once the download has started. @see <a href="http://www.ietf.org/rfc/rfc1590.txt">RFC 1590, defining Media Types</a> */ COLUMN_MEDIA_TYPE : "media_type", /** Total size of the download in bytes. This will initially be -1 and will be filled in once the download starts. */ COLUMN_TOTAL_SIZE_BYTES : "total_size", /** Uri where downloaded file will be stored. If a destination is supplied by client, that URI will be used here. Otherwise, the value will initially be null and will be filled in with a generated URI once the download has started. */ COLUMN_LOCAL_URI : "local_uri", /** Path to the downloaded file on disk. <p> Note that apps may not have filesystem permissions to directly access this path. Instead of trying to open this path directly, apps should use {@link ContentResolver#openFileDescriptor(Uri, String)} to gain access. @deprecated apps should transition to using {@link ContentResolver#openFileDescriptor(Uri, String)} instead. */ COLUMN_LOCAL_FILENAME : "local_filename", /** Current status of the download, as one of the STATUS_* constants. */ COLUMN_STATUS : "status", /** Provides more detail on the status of the download. Its meaning depends on the value of {@link #COLUMN_STATUS}. When {@link #COLUMN_STATUS} is {@link #STATUS_FAILED}, this indicates the type of error that occurred. If an HTTP error occurred, this will hold the HTTP status code as defined in RFC 2616. Otherwise, it will hold one of the ERROR_* constants. When {@link #COLUMN_STATUS} is {@link #STATUS_PAUSED}, this indicates why the download is paused. It will hold one of the PAUSED_* constants. If {@link #COLUMN_STATUS} is neither {@link #STATUS_FAILED} nor {@link #STATUS_PAUSED}, this column's value is undefined. @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1">RFC 2616 status codes</a> */ COLUMN_REASON : "reason", /** Number of bytes download so far. */ COLUMN_BYTES_DOWNLOADED_SO_FAR : "bytes_so_far", /** Timestamp when the download was last modified, in {@link System#currentTimeMillis System.currentTimeMillis()} (wall clock time in UTC). */ COLUMN_LAST_MODIFIED_TIMESTAMP : "last_modified_timestamp", /** The URI to the corresponding entry in MediaProvider for this downloaded entry. It is used to delete the entries from MediaProvider database when it is deleted from the downloaded list. */ COLUMN_MEDIAPROVIDER_URI : "mediaprovider_uri", /**@hide */ COLUMN_MEDIASTORE_URI : "mediastore_uri", /** @hide */ COLUMN_ALLOW_WRITE : "allow_write", /** Value of {@link #COLUMN_STATUS} when the download is waiting to start. */ STATUS_PENDING : "1", /** Value of {@link #COLUMN_STATUS} when the download is currently running. */ STATUS_RUNNING : "2", /** Value of {@link #COLUMN_STATUS} when the download is waiting to retry or resume. */ STATUS_PAUSED : "4", /** Value of {@link #COLUMN_STATUS} when the download has successfully completed. */ STATUS_SUCCESSFUL : "8", /** Value of {@link #COLUMN_STATUS} when the download has failed (and will not be retried). */ STATUS_FAILED : "16", /** Value of COLUMN_ERROR_CODE when the download has completed with an error that doesn't fit under any other error code. */ ERROR_UNKNOWN : "1000", /** Value of {@link #COLUMN_REASON} when a storage issue arises which doesn't fit under any other error code. Use the more specific {@link #ERROR_INSUFFICIENT_SPACE} and {@link #ERROR_DEVICE_NOT_FOUND} when appropriate. */ ERROR_FILE_ERROR : "1001", /** Value of {@link #COLUMN_REASON} when an HTTP code was received that download manager can't handle. */ ERROR_UNHANDLED_HTTP_CODE : "1002", /** Value of {@link #COLUMN_REASON} when an error receiving or processing data occurred at the HTTP level. */ ERROR_HTTP_DATA_ERROR : "1004", /** Value of {@link #COLUMN_REASON} when there were too many redirects. */ ERROR_TOO_MANY_REDIRECTS : "1005", /** Value of {@link #COLUMN_REASON} when there was insufficient storage space. Typically, this is because the SD card is full. */ ERROR_INSUFFICIENT_SPACE : "1006", /** Value of {@link #COLUMN_REASON} when no external storage device was found. Typically, this is because the SD card is not mounted. */ ERROR_DEVICE_NOT_FOUND : "1007", /** Value of {@link #COLUMN_REASON} when some possibly transient error occurred but we can't resume the download. */ ERROR_CANNOT_RESUME : "1008", /** Value of {@link #COLUMN_REASON} when the requested destination file already exists (the download manager will not overwrite an existing file). */ ERROR_FILE_ALREADY_EXISTS : "1009", /** Value of {@link #COLUMN_REASON} when the download has failed because of {@link NetworkPolicyManager} controls on the requesting application. @hide */ ERROR_BLOCKED : "1010", /** Value of {@link #COLUMN_REASON} when the download is paused because some network error occurred and the download manager is waiting before retrying the request. */ PAUSED_WAITING_TO_RETRY : "1", /** Value of {@link #COLUMN_REASON} when the download is waiting for network connectivity to proceed. */ PAUSED_WAITING_FOR_NETWORK : "2", /** Value of {@link #COLUMN_REASON} 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. */ PAUSED_QUEUED_FOR_WIFI : "3", /** Value of {@link #COLUMN_REASON} when the download is paused for some other reason. */ PAUSED_UNKNOWN : "4", /** Broadcast intent action sent by the download manager when a download completes. */ ACTION_DOWNLOAD_COMPLETE : "android.intent.action.DOWNLOAD_COMPLETE", /** 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. */ ACTION_NOTIFICATION_CLICKED : "android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED", /** Intent action to launch an activity to display all downloads. */ ACTION_VIEW_DOWNLOADS : "android.intent.action.VIEW_DOWNLOADS", /** Intent extra included with {@link #ACTION_VIEW_DOWNLOADS} to start DownloadApp in sort-by-size mode. */ INTENT_EXTRAS_SORT_BY_SIZE : "android.app.DownloadManager.extra_sortBySize", /** Intent extra included with {@link #ACTION_DOWNLOAD_COMPLETE} intents, indicating the ID (as a long) of the download that just completed. */ EXTRA_DOWNLOAD_ID : "extra_download_id", /** When clicks on multiple notifications are received, the following provides an array of download ids corresponding to the download notification that was clicked. It can be retrieved by the receiver of this Intent using {@link android.content.Intent#getLongArrayExtra(String)}. */ EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS : "extra_click_download_ids", /**{@hide} */ ACTION_DOWNLOAD_COMPLETED : "android.intent.action.DOWNLOAD_COMPLETED", /** columns to request from DownloadProvider. @hide */ UNDERLYING_COLUMNS : "null", /**Makes this object access the download provider through /all_downloads URIs rather than /my_downloads URIs, for clients that have permission to do so. @hide */ setAccessAllDownloads : function( ) {}, /**{@hide} */ setAccessFilename : function( ) {}, /**Enqueue a new download. The download will start automatically once the download manager is ready to execute it and connectivity is available. @param {Object {DownloadManager.Request}} request the parameters specifying this download @return {Number} an ID for the download, unique across the system. This ID is used to make future calls related to this download. */ enqueue : function( ) {}, /**Marks the specified download as 'to be deleted'. This is done when a completed download is to be removed but the row was stored without enough info to delete the corresponding metadata from Mediaprovider database. Actual cleanup of this row is done in DownloadService. @param {Object {long[]}} ids the IDs of the downloads to be marked 'deleted' @return {Number} the number of downloads actually updated @hide */ markRowDeleted : function( ) {}, /**Cancel downloads and remove them from the download manager. Each download will be stopped if it was running, and it will no longer be accessible through the download manager. If there is a downloaded file, partial or complete, it is deleted. @param {Object {long[]}} ids the IDs of the downloads to remove @return {Number} the number of downloads actually removed */ remove : function( ) {}, /**Query the download manager about downloads that have been requested. @param {Object {DownloadManager.Query}} query parameters specifying filters for this query @return {Object {android.database.Cursor}} a Cursor over the result set of downloads, with columns consisting of all the COLUMN_* constants. */ query : function( ) {}, /** @hide */ query : function( ) {}, /**Open a downloaded file for reading. The download must have completed. @param {Number} id the ID of the download @return {Object {android.os.ParcelFileDescriptor}} a read-only {@link ParcelFileDescriptor} @throws FileNotFoundException if the destination file does not already exist */ openDownloadedFile : function( ) {}, /**Returns the {@link Uri} of the given downloaded file id, if the file is downloaded successfully. Otherwise, null is returned. @param {Number} id the id of the downloaded file. @return {Object {android.net.Uri}} the {@link Uri} of the given downloaded file id, if download was successful. null otherwise. */ getUriForDownloadedFile : function( ) {}, /**Returns the media type of the given downloaded file id, if the file was downloaded successfully. Otherwise, null is returned. @param {Number} id the id of the downloaded file. @return {String} the media type of the given downloaded file id, if download was successful. null otherwise. */ getMimeTypeForDownloadedFile : function( ) {}, /**Restart the given downloads, which must have already completed (successfully or not). This method will only work when called from within the download manager's process. @param {Object {long[]}} ids the IDs of the downloads @hide */ restartDownload : function( ) {}, /**Force the given downloads to proceed even if their size is larger than {@link #getMaxBytesOverMobile}(Context). @hide */ forceDownload : function( ) {}, /**Returns maximum size, in bytes, of downloads that may go over a mobile connection; or null if there's no limit @param {Object {Context}} context the {@link Context} to use for accessing the {@link ContentResolver} @return {Number} maximum size, in bytes, of downloads that may go over a mobile connection; or null if there's no limit */ getMaxBytesOverMobile : function( ) {}, /**Rename the given download if the download has completed @param {Object {Context}} context the {@link Context} to use in case need to update MediaProvider @param {Number} id the downloaded id @param {String} displayName the new name to rename to @return {Boolean} true if rename was successful, false otherwise @hide */ rename : function( ) {}, /**Returns recommended maximum size, in bytes, of downloads that may go over a mobile connection; or null if there's no recommended limit. The user will have the option to bypass this limit. @param {Object {Context}} context the {@link Context} to use for accessing the {@link ContentResolver} @return {Number} recommended maximum size, in bytes, of downloads that may go over a mobile connection; or null if there's no recommended limit. */ getRecommendedMaxBytesOverMobile : function( ) {}, /**{@hide} */ isActiveNetworkExpensive : function( ) {}, /**{@hide} */ getActiveNetworkWarningBytes : function( ) {}, /**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). <p> It is helpful to make the file scannable by MediaScanner by setting the param isMediaScannerScannable to true. It makes the file visible in media managing applications such as Gallery App, which could be a useful purpose of using this API. <p> For applications targeting {@link android.os.Build.VERSION_CODES#Q} or above, {@code path} must be within directories owned by the application {e.g. {@link Context#getExternalFilesDir(String)}} or if the application is running under the legacy storage model (see {@link android.R.styleable#AndroidManifestApplication_requestLegacyExternalStorage android:requestLegacyExternalStorage}), {@code path} can also be within the top-level Downloads directory (as returned by {@link Environment#getExternalStoragePublicDirectory(String)} with {@link Environment#DIRECTORY_DOWNLOADS}). @param {String} title the title that would appear for this file in Downloads App. @param {String} description the description that would appear for this file in Downloads App. @param {Boolean} isMediaScannerScannable true if the file is to be scanned by MediaScanner. Files scanned by MediaScanner appear in the applications used to view media (for example, Gallery app). @param {String} mimeType mimetype of the file. @param {String} path absolute pathname to the file. The file should be world-readable, so that it can be managed by the Downloads App and any other app that is used to read it (for example, Gallery app to display the file, if the file contents represent a video/image). @param {Number} length length of the downloaded file @param {Boolean} showNotification true if a notification is to be sent, false otherwise @return {Number} an ID for the download entry added to the downloads app, unique across the system This ID is used to make future calls related to this download. @deprecated Apps should instead contribute files to {@link android.provider.MediaStore.Downloads} collection to make them available to user as part of Downloads. */ addCompletedDownload : function( ) {}, /**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). <p> It is helpful to make the file scannable by MediaScanner by setting the param isMediaScannerScannable to true. It makes the file visible in media managing applications such as Gallery App, which could be a useful purpose of using this API. <p> For applications targeting {@link android.os.Build.VERSION_CODES#Q} or above, {@code path} must be within directories owned by the application {e.g. {@link Context#getExternalFilesDir(String)}} or if the application is running under the legacy storage model (see {@link android.R.styleable#AndroidManifestApplication_requestLegacyExternalStorage android:requestLegacyExternalStorage}), {@code path} can also be within the top-level Downloads directory (as returned by {@link Environment#getExternalStoragePublicDirectory(String)} with {@link Environment#DIRECTORY_DOWNLOADS}). @param {String} title the title that would appear for this file in Downloads App. @param {String} description the description that would appear for this file in Downloads App. @param {Boolean} isMediaScannerScannable true if the file is to be scanned by MediaScanner. Files scanned by MediaScanner appear in the applications used to view media (for example, Gallery app). @param {String} mimeType mimetype of the file. @param {String} path absolute pathname to the file. The file should be world-readable, so that it can be managed by the Downloads App and any other app that is used to read it (for example, Gallery app to display the file, if the file contents represent a video/image). @param {Number} length length of the downloaded file @param {Boolean} showNotification true if a notification is to be sent, false otherwise @param {Object {Uri}} uri the original HTTP URI of the download @param {Object {Uri}} referer the HTTP Referer for the download @return {Number} an ID for the download entry added to the downloads app, unique across the system This ID is used to make future calls related to this download. @deprecated Apps should instead contribute files to {@link android.provider.MediaStore.Downloads} collection to make them available to user as part of Downloads. */ addCompletedDownload : function( ) {}, /**<p> For applications targeting {@link android.os.Build.VERSION_CODES#Q} or above, {@code path} must be within directories owned by the application {e.g. {@link Context#getExternalFilesDir(String)}} or if the application is running under the legacy storage model (see {@link android.R.styleable#AndroidManifestApplication_requestLegacyExternalStorage android:requestLegacyExternalStorage}), {@code path} can also be within the top-level Downloads directory (as returned by {@link Environment#getExternalStoragePublicDirectory(String)} with {@link Environment#DIRECTORY_DOWNLOADS}). @deprecated Apps should instead contribute files to {@link android.provider.MediaStore.Downloads} collection to make them available to user as part of Downloads. {@hide} */ addCompletedDownload : function( ) {}, /**<p> For applications targeting {@link android.os.Build.VERSION_CODES#Q} or above, {@code path} must be within directories owned by the application {e.g. {@link Context#getExternalFilesDir(String)}} or if the application is running under the legacy storage model (see {@link android.R.styleable#AndroidManifestApplication_requestLegacyExternalStorage android:requestLegacyExternalStorage}), {@code path} can also be within the top-level Downloads directory (as returned by {@link Environment#getExternalStoragePublicDirectory(String)} with {@link Environment#DIRECTORY_DOWNLOADS}). {@hide} @deprecated Apps should instead contribute files to {@link android.provider.MediaStore.Downloads} collection to make them available to user as part of Downloads. */ addCompletedDownload : function( ) {}, /**Get the DownloadProvider URI for the download with the given ID. @hide */ getDownloadUri : function( ) {}, };