问题描述
我有以下的code:
function wait(){
$(document).ready(function() {
//alert("Dentro de ready");
document.addEventListener("deviceready", init(), true);
});
}
其中等待是从onload事件称为JavaScript函数。我用的是onload事件,以及$(文件)。就绪和deviceready活动,以确保当我开始编写每一件事被加载。
Where "wait" is a Javascript function called from the onload event. I use the onload event, as well as $(document).ready and "deviceready" event to make sure every single thing is loaded when i start coding.
在的init()方法做了一些事情,然后调用下面的方法:
The "init()" method does a few things and then calls the following method:
function download_img(imgToDownload){
var url = remote_url+imgToDownload; // image url
alert("img url: "+url);
try{
window.requestFileSystem(**LocalFileSystem**.PERSISTENT, 0,
function (fs) {
var imagePath = fs.root.fullPath +"/"+ imgToDownload; // full file path
var fileTransfer = new FileTransfer();
fileTransfer.download(url, imagePath,
function (entry) {
alert("OK: " + entry.fullPath); // entry is fileEntry object
},
function (error) {
alert("download error source " + error.source);
alert("download error target " + error.target);
alert("upload error code" + error.code);
alert("http_status"+error.http_status);
}
);
}
);
}catch(err){
alert(err.message);
}
}
在那里我得到的错误信息:LocalFileSystem没有定义。
Where I get the error message: "LocalFileSystem is not defined".
我的config.xml文件是:
My config.xml is:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.lamakun.mancomunidad"
version = "3.0.0">
<name>PhoneGap Build Application</name>
<description>
A simple PhoneGap Build application.
</description>
<author href="https://example.com" email="[email protected]">
Your Name
</author>
<preference name="phonegap-version" value="2.2.0" />
<access origin="http://www.mytests.es" subdomains="true"/>
</widget>
在情况下,我可能会添加任何权限,即使我觉得现在我有他们所有。谁能给我一个线索上?
In case I might add any permission, even though I think right now I have them all.Can anyone give me a clue on that?
推荐答案
这不是:
document.addEventListener("deviceready", init(), true);
应该是:
document.addEventListener("deviceready", init, true);
具有()初始化调用该函数的deviceready事件是发射前一刻之后。
having the () after init calls that function immediately before the deviceready event is fired.
这篇关于LocalFileSystem没有在Android中定义的PhoneGap(构建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!