java.lang.Object | |
↳ | android.app.DownloadManager.Request |
This class contains all the information necessary to request a new download. The URI is the
only required parameter.
Note that the default download destination is a shared volume where the system might delete
your file if it needs to reclaim space for system use. If this is a problem, use a location
on external storage (see setDestinationUri(Uri)
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | NETWORK_MOBILE |
Bit flag for setAllowedNetworkTypes(int) corresponding to
TYPE_MOBILE .
|
|||||||||
int | NETWORK_WIFI |
Bit flag for setAllowedNetworkTypes(int) corresponding to
TYPE_WIFI .
|
|||||||||
int | VISIBILITY_HIDDEN | This download doesn't show in the UI or in the notifications. | |||||||||
int | VISIBILITY_VISIBLE | This download is visible but only shows in the notifications while it's in progress. | |||||||||
int | VISIBILITY_VISIBLE_NOTIFY_COMPLETED | This download is visible and shows in the notifications while in progress and after completion. | |||||||||
int | VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION | This download shows in the notifications after completion ONLY. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add an HTTP header to be included with the download request.
| |||||||||||
If the file to be downloaded is to be scanned by MediaScanner, this method
should be called before
enqueue(Request) is called.
| |||||||||||
Restrict the types of networks over which this download may proceed.
| |||||||||||
Set whether this download may proceed over a metered network
connection.
| |||||||||||
Set whether this download may proceed over a roaming connection.
| |||||||||||
Set a description of this download, to be displayed in notifications (if enabled)
| |||||||||||
Set the local destination for the downloaded file to a path within
the application's external files directory (as returned by
getExternalFilesDir(String) .
| |||||||||||
Set the local destination for the downloaded file to a path within
the public external storage directory (as returned by
getExternalStoragePublicDirectory(String) ).
| |||||||||||
Set the local destination for the downloaded file.
| |||||||||||
Set the MIME content type of this download.
| |||||||||||
Control whether a system notification is posted by the download manager while this
download is running or when it is completed.
| |||||||||||
This method was deprecated
in API level 11.
use
setNotificationVisibility(int)
| |||||||||||
Set the title of this download, to be displayed in notifications (if enabled).
| |||||||||||
Set whether this download should be displayed in the system's Downloads UI.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Bit flag for setAllowedNetworkTypes(int)
corresponding to
TYPE_MOBILE
.
Bit flag for setAllowedNetworkTypes(int)
corresponding to
TYPE_WIFI
.
This download doesn't show in the UI or in the notifications.
This download is visible but only shows in the notifications while it's in progress.
This download is visible and shows in the notifications while in progress and after completion.
This download shows in the notifications after completion ONLY.
It is usuable only with
addCompletedDownload(String, String, boolean, String, String, long, boolean)
.
uri | the HTTP or HTTPS URI to download. |
---|
Add an HTTP header to be included with the download request. The header will be added to the end of the list.
header | HTTP header name |
---|---|
value | header value |
If the file to be downloaded is to be scanned by MediaScanner, this method
should be called before enqueue(Request)
is called.
Restrict the types of networks over which this download may proceed.
By default, all network types are allowed. Consider using
setAllowedOverMetered(boolean)
instead, since it's more
flexible.
flags | any combination of the NETWORK_* bit flags. |
---|
Set whether this download may proceed over a metered network connection. By default, metered networks are allowed.
Set whether this download may proceed over a roaming connection. By default, roaming is allowed.
allowed | whether to allow a roaming connection to be used |
---|
Set a description of this download, to be displayed in notifications (if enabled)
Set the local destination for the downloaded file to a path within
the application's external files directory (as returned by
getExternalFilesDir(String)
.
The downloaded file is not scanned by MediaScanner. But it can be
made scannable by calling allowScanningByMediaScanner()
.
context | the Context to use in determining the external
files directory |
---|---|
dirType | the directory type to pass to
getExternalFilesDir(String) |
subPath | the path within the external directory, including the destination filename |
IllegalStateException | If the external storage directory cannot be found or created. |
---|
Set the local destination for the downloaded file to a path within
the public external storage directory (as returned by
getExternalStoragePublicDirectory(String)
).
The downloaded file is not scanned by MediaScanner. But it can be
made scannable by calling allowScanningByMediaScanner()
.
dirType | the directory type to pass to getExternalStoragePublicDirectory(String) |
---|---|
subPath | the path within the external directory, including the destination filename |
IllegalStateException | If the external storage directory cannot be found or created. |
---|
Set the local destination for the downloaded file. Must be a file URI to a path on external storage, and the calling application must have the WRITE_EXTERNAL_STORAGE permission.
The downloaded file is not scanned by MediaScanner.
But it can be made scannable by calling allowScanningByMediaScanner()
.
By default, downloads are saved to a generated filename in the shared download cache and may be deleted by the system at any time to reclaim space.
Set the MIME content type of this download. This will override the content type declared in the server's response.
Control whether a system notification is posted by the download manager while this
download is running or when it is completed.
If enabled, the download manager posts notifications about downloads
through the system NotificationManager
.
By default, a notification is shown only when the download is in progress.
It can take the following values: VISIBILITY_HIDDEN
,
VISIBILITY_VISIBLE
,
VISIBILITY_VISIBLE_NOTIFY_COMPLETED
.
If set to VISIBILITY_HIDDEN
, this requires the permission
android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.
visibility | the visibility setting value |
---|
This method was deprecated
in API level 11.
use setNotificationVisibility(int)
Control whether a system notification is posted by the download manager while this
download is running. If enabled, the download manager posts notifications about downloads
through the system NotificationManager
. By default, a notification is
shown.
If set to false, this requires the permission
android.permission.DOWNLOAD_WITHOUT_NOTIFICATION.
show | whether the download manager should show a notification for this download. |
---|
Set the title of this download, to be displayed in notifications (if enabled). If no title is given, a default one will be assigned based on the download filename, once the download starts.
Set whether this download should be displayed in the system's Downloads UI. True by default.
isVisible | whether to display this download in the Downloads UI |
---|