android - Basic Phonegap Download issue -
hi have following code got tutorial. have run on device , doesn't anything. new phonegap , js can 1 please.
function onbodyload(){ document.addeventlistener("deviceready", ondeviceready, false); } function downloadfile(){ window.requestfilesystem( localfilesystem.persistent, 0, function onfilesystemsuccess(filesystem) { filesystem.root.getfile( "dummy.html", {create: true, exclusive: false}, function gotfileentry(fileentry){ var spath = fileentry.fullpath.replace("sample.html",""); var filetransfer = new filetransfer(); fileentry.remove(); filetransfer.download( "http://www.webfoxers.com/devscope.pdf",function(thefile) { console.l og("download complete: " + thefile.touri()); showlink(thefile.touri()); }, function(error) { console.log("download error source " + error.source); console.log("download error target " + error.target); console.log("upload error code: " + error.code); } ); }, fail); }, fail); } function showlink(url){ alert(url); var divel = document.getelementbyid("ready"); var aelem = document.createelement("a"); aelem.setattribute("target", "_blank"); aelem.setattribute("href", url); aelem.appendchild(document.createtextnode("ready! click open.")) divel.appendchild(aelem); } function fail(evt) { console.log(evt.target.error.code); } function ondeviceready() { // thing! downloadfile(); }
here logcat file eclipse:07-31 13:25:52.632:
d/droidgap(4366): droidgap.oncreate() 07-31 13:25:52.712: d/dalvikvm(4366): gc_external_alloc freed 129k, 48% free 2872k/5447k, external 2032k/2137k, paused 68ms 07-31 13:25:52.772: d/cordovawebview(4366): origin allow: http://127.0.0.1* 07-31 13:25:52.772: i/cordovalog(4366): found log level debug 07-31 13:25:52.772: i/cordovalog(4366): changing log level debug(3) 07-31 13:25:52.772: i/cordovalog(4366): found preference usebrowserhistory=false 07-31 13:25:52.792: d/cordovalog(4366): found preference usebrowserhistory=false 07-31 13:25:52.812: d/droidgap(4366): droidgap.init() 07-31 13:25:52.822: d/cordovawebview(4366): >>> loadurl(file:///android_asset/www/index.html) 07-31 13:25:52.822: d/pluginmanager(4366): init() 07-31 13:25:52.862: d/cordovawebview(4366): >>> loadurlnow() 07-31 13:25:52.882: d/droidgap(4366): onmessage(onpagestarted,file:///android_asset/www/index.html) 07-31 13:25:52.882: d/softkeyboarddetect(4366): ignore event 07-31 13:25:52.992: d/softkeyboarddetect(4366): ignore event 07-31 13:25:53.092: d/cordova(4366): onpagefinished(file:///android_asset/www/index.html) 07-31 13:25:53.092: d/cordovawebview(4366): >>> loadurlnow() 07-31 13:25:53.112: d/droidgap(4366): onmessage(onnativeready,null) 07-31 13:25:53.122: d/droidgap(4366): onmessage(onpagefinished,file:///android_asset/www/index.html) 07-31 13:25:55.142: d/droidgap(4366): onmessage(spinner,stop)
from code posted, file.download (from memory) has second parameter file path save. think missed 1 in code.
regards, radu
Comments
Post a Comment