Im buildning an application with intel xdk for android and ios. Im having trouble saving a pdf on the sdcard in android. im able to get the file directory of the unit and my alert text show that im progressing fine. But when i try to save the pdf nothing happens. The application just skip the "fileTransfer.download(...)", no exception, no nothing.
Im probebly missing something but, is filetransfer not supported? been searching but no luck. All ideas are most welcome :o)
/Anders my code:
function download()
{
window.appRootDirName = "download_test";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("device is ready");
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function fail() {
alert("failed to get filesystem");
}
function gotFS(fileSystem) {
alert("filesystem got");
window.fileSystem = fileSystem;
fileSystem.root.getDirectory(window.appRootDirName, {
create: true,
exclusive: false
}, dirReady, fail);
}
function dirReady(entry) {
window.appRootDir = entry;
alert("application dir is ready");
}
var filePathx = window.appRootDir.fullPath + "/test.pdf";
alert(filePathx);
try{
downloadFile = function() {
var fileTransfer = new FileTransfer();
var url = "http://myserver/file.pdf";
var filePath = window.appRootDir.fullPath + "/test.pdf";
fileTransfer.download(
url, filePath, function(entry) {
alert("download complete: " + entry.fullPath);
}, function(error) {
alert("download error" + error.source);
});
}
}
catch(e)
{
alert("error in filetransfer.download: " + e.message);
}
}
You need to include the WRITE_EXTERNAL_STORAGE permissions in the manifest file but the Intel XDK does not provide a UI to enable this permission. I will file a bug for you. http://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE
You you should be able to use the Cordova for Android build. There is a PhoneGap Audio example application that I just tested but it does not work. I have filed an bug for the Intel XDK.
You can try a Cordova Android build by doing the following:
Use Intel XDK version 0876:
Install the .apk using adb install .apk
This app should create and save an audio file using Cordova APIs. I just tried this on a 4.0 and Android 2.3 phone and it did not work. Bug filed for you and I will update this post as the issue is tracked.
Documentation can be found at https://software.intel.com/en-us/html5/articles/using-the-cordova-for-android-ios-etc-build-option
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.