To provide the user access to Internet resources, you must learn how to check the state of a download operation and retrieve relevant information:
To be able to monitor the download state, you need the download ID, which is the return value of the start() method of the DownloadManager interface:
downloadId = webapis.download.start(downloadRequest, listener);
Use the getState() method with the download ID as a parameter to get the current state:
var state = webapis.download.getState(downloadId);
The method returns a DownloadState enumerator value.
Use the getDownloadRequest() method with the download ID as a parameter to get the download request details that the user has previously set:
var downloadRequest = webapis.download.getDownloadRequest(downloadId);
The method returns the DownloadRequest information which is used as the parameter when starting the download.
Use the getMIMEType() method with the download ID as a parameter to get the MIME type of the file that you have started downloading:
var MIMEType = webapis.download.getMIMEType(downloadId);
The method returns the MIME type the target file which has started downloading.