User Tools

Site Tools


built_in:downloader

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
built_in:downloader [2015/01/08 14:13]
thomaskwd
built_in:downloader [2018/04/19 23:14] (current)
Line 2: Line 2:
  
 For downloading files (including zip files) //direct to sdcard//, you can use the app.CreateDownloader() method like this: For downloading files (including zip files) //direct to sdcard//, you can use the app.CreateDownloader() method like this:
 +<code>dload = app.CreateDownloader();</code>
  
 ===== Methods ===== ===== Methods =====
-^Method ^Description ^ +^ Method                                   ^ Description                                                                                                                                       
-|Downloader.Download() |You can pass a comma seperated list of file urls to download. | +| Downloader.Download(sourceURI,destPath Start download. You can pass a comma seperated list of file urls to download. **destPath** should be a valid and accessible folder on the device  
-|Downloader.IsComplete() | | +| Downloader.GetProgress()                 returns fract value 0..1, but "NaN" if not yet started                                                                                            
-|Downloader.GetProgress() | | +| Downloader.GetSize()                                                                                                                                                                       
-|Downloader.GetSize() | | +| Downloader.IsComplete()                  returns true/false                                                                                                                                
-|Downloader.SetOnComplete(callback) | |+| Downloader.SetOnComplete(callback)       Should be done before starting the download.                                                                                                      |
  
-Example code snippet: +=====Example code snippet ===== 
-<code>+<code javascript>
 dload = app.CreateDownloader(); dload = app.CreateDownloader();
 dload.SetOnComplete( dload_OnComplete ); dload.SetOnComplete( dload_OnComplete );
 dload.Download( srcFileUrl, targetDir ); dload.Download( srcFileUrl, targetDir );
  
-function dload_OnComplete() {+function dload_OnComplete() 
 +{
     // we know download is ready now     // we know download is ready now
     // (but not if success or not)     // (but not if success or not)
Line 23: Line 25:
  
 </code> </code>
 +
 +===== Options =====
 +
 +^ Option       ^ Description                                          ^
 +| NoDialog     | Hides the default download dialog                    |
  
 Thanks to Dave (forum: https://groups.google.com/d/msg/androidscript/1_SnH886xT4/OlDVPxZ5bDwJ) Thanks to Dave (forum: https://groups.google.com/d/msg/androidscript/1_SnH886xT4/OlDVPxZ5bDwJ)
built_in/downloader.1420726384.txt.gz · Last modified: 2015/01/08 22:13 (external edit)