Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

[Android] - download multiple images

$
0
0

hello I try to download multiple images in a row. I'm stuck for several days and could not find the solution. Currently I have this, but only the last image is recorded.

for (var j = 1; j <= nb_exercices; j++) { loadingLabel.text = 'Téléchargement de l\'exercice ' + j + ' / ' + nb_exercices;

var id = jsonObject.packExercices[j].id;

var f = id;                 

var xhr3 = Titanium.Network.createHTTPClient({
    onload: function() {
        var source = id + '.png';
        f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,source);
        f.write(this.responseData); // write to the file
        Ti.App.fireEvent('image_downloaded', {filepath:f.nativePath});
    }
});

var lien = 'http://myURL/' + id + '.png';                   
xhr3.open('GET',lien);
xhr3.send();

if (j &gt;= nb_exercices)
{                       
    actInd.hide();
    loadingLabel.text = 'Téléchargement terminé';
}                       

}

Can you help me please ?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>