PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Overview
  • How to?
  • Adding a download
  • Monitoring a download
  • Removing a download
  • WLanguage functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
Starting with version 27, files can be downloaded in the background, using the system download manager. Therefore, it is no longer necessary to keep the application open to prompt the user to download a file. The download manager allows you to download large files and generate a notification when downloads are complete.
How to?

Adding a download

To propose a download in your Android application:
  1. Define a download request with a variable of type DownloadParameter. This variable contains multiple properties, but only one is really necessary: the Source property which corresponds to the URI of the file to download.
  2. Add the download in the download manager with DownloadAdd. Once added, the download manager will start the download as soon as possible.
Remark: Download end procedure
To be notified when a download is completed, you can specify a procedure that will be called at the end of the download. To do so, it is necessary to specify the procedure to call in the ProcedureEnd property of the DownloadParameter variable.
  • If the application was closed before the end of the download, it will be restarted to execute the procedure when the download is completed.
  • If the procedure returns True, the download will be deleted as well as the downloaded file. Otherwise, the download will be kept in the download manager and the file will not be deleted.

Monitoring a download

To monitor the download in the Android application, retrieve the download details with DownloadAdd, specifying the download identifier provided by DownloadGetInfo. This information is stored in a variable of type DownloadInfo.
If there is an error during the download, the download end procedure is started. The Status property of the DownloadInfo variable is set to downloadStatusFailed. In this case, the StatusDetails property can be used to determine the cause of the error.
To retrieve all the downloads started by the application in the download manager, use DownloadList.

Removing a download

To remove a download from the download manager, use DownloadRemove and specify the identifier of the download to be removed. This function will cancel the download and remove it from the download manager, as well as the downloaded file, if it exists.
WLanguage functions
The following WLanguage functions are used to manage downloads:
DownloadAddAdds a new download in the device's download manager.
DownloadListLists the downloads from the current application in the download manager.
DownloadGetInfoRetrieves the details of a download present in the download manager.
DownloadRemoveCancels a download by removing it from the download manager, and deletes any existing files.
Remarks:
  • Using download functions automatically adds the INTERNET permission to the list of permissions required by the application. The DOWNLOAD_WITHOUT_NOTIFICATION permission is also added if the downloadNotifNone constant is used with the NotificationMode property of the DownloadParameter variable.
  • When running the application in the simulator, download functions will have no effect.
Related Examples:
Android Downloads Android (WINDEV Mobile): Android Downloads
[ + ] This example illustrates background downloads in WINDEV Mobile and Android.
It is no longer necessary to keep the application open to propose the download of a file. The download manager allows you to download large files and to notify the application when the downloads are finished.
Minimum version required
  • Version 27
Comments
Click [Add] to post a comment