在android phonegap中打开一个vcs文件

时间:2014-02-28 09:35:10

标签: android vcalendar cordova-2.7.0

我从远程服务器下载vcs文件,用于在android phonegap ... vcs文件中正确下载日历上的事件。我的问题是它剂量提示我打开文件..因此用户无法加载事件自动..可以任意给我一个插件或任何其他等效的代码..

PS:我是android的新手:)

enter code here

<script>
document.addEventListener("deviceready", onDeviceReady, false);
     function onSuccess(fileSystem) {
    console.log(fileSystem.name);
    console.log(fileSystem.root.name);
}
function onDeviceReady(){
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null);   
}

function win(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
    console.log("read success");
    console.log(evt.target.result);
};
reader.readAsText(file);
};

 var fail = function(evt) {
console.log(error.code); 
};
 function syncCal(){

var fileTransfer = new FileTransfer();
var uri = encodeURI(server address);
var filePath =  'file:///sdcard/london3.vcs';
fileTransfer.download(
uri,
    filePath,
    function(entry) {
        console.log("download complete: " + entry.fullPath);
        entry.file(win, fail);
        entry.file.open;
    },
    function(error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("upload error code" + error.code);
    },
    false,
    {
        headers: {
            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
        }
    }
)

}

0 个答案:

没有答案