2012-08-03 36 views
1

我有一个在Android和iOS上正常工作的应用程序,但目前在BlackBerry(OS 6.0+)上失败。该应用程序用于处理所有3种风格,但自从将应用程序转换为动态下载更新(而不是每次对某些Javascript稍作更改时重新发布应用程序)时,该应用程序无法通过getDirectory函数。我正在使用Cordova 1.8.1。Phonegap/Cordova getDirectory在BlackBerry上失败

这里是我的JavaScript代码的开始部分,当设备准备好执行:

function onDeviceReady(){ 
    // get the filesystem setup and run the pre-loader (follow the callback road) 
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail_FS); 
} 

function gotFS(fileSystem) { 
    fileSystem.root.getDirectory("data", {create: true}, gotDir, fail_GD); 
} 

function gotDir(dir) { 
    console.log("got dir"); 
    DATADIR = dir; 
    // code for downloading/updating files goes here 
    // left out for brevity and lack of relevance at this point 
} 

function fail_FS(error){ 
    fail(error,'requestFileSystem'); 
} 

function fail_GD(error){ 
    fail(error,'getDirectory'); 
} 

function fail(error,call){ 
    console.log("ERROR: "+call); 
    console.log(JSON.stringify(error)); 
} 

我得到的1的错误代码从getDirectory调用(GotFS功能)。我添加了额外的评论来测试。这是我知道的:

文件系统= '执着' fileSystem.root.name = “” fileSystem.root.fullPath = '文件:///店'

我上选中的文件科尔多瓦herehere和这里是我在我的config.xml

<feature id="blackberry.system" required="true" version="1.0.0.0" /> 
<feature id="org.apache.cordova" required="true" version="1.0.0" /> 
<feature id="blackberry.find" required="true" version="1.0.0.0" /> 
<feature id="blackberry.identity" required="true" version="1.0.0.0" /> 
<feature id="blackberry.pim.Address" required="true" version="1.0.0.0" /> 
<feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" /> 
<feature id="blackberry.io.file" required="true" version="1.0.0.0" /> 
<feature id="blackberry.utils" required="true" version="1.0.0.0" /> 
<feature id="blackberry.io.dir" required="true" version="1.0.0.0" /> 
<feature id="blackberry.app" required="true" version="1.0.0.0" /> 
<feature id="blackberry.app.event" required="true" version="1.0.0.0" /> 
<feature id="blackberry.system.event" required="true" version="1.0.0.0"/> 
<feature id="blackberry.widgetcache" required="true" version="1.0.0.0"/> 
<feature id="blackberry.media.camera" /> 
<feature id="blackberry.invoke" /> 
<feature id="blackberry.invoke.BrowserArguments" /> 
<feature id="blackberry.identity" /> 
<feature id="blackberry.ui.dialog" /> 
<feature id="blackberry.system" /> 

<access subdomains="true" uri="file:///store" /> 
<access subdomains="true" uri="file:///store/data" /> 
<access subdomains="true" uri="file:///SDCard" /> 
<access subdomains="true" uri="*" /> 
<rim:permissions> 
    <rim:permit>use_camera</rim:permit> 
    <rim:permit>read_device_identifying_information</rim:permit> 
    <rim:permit>access_shared</rim:permit> 
    <rim:permit>read_geolocation</rim:permit> 
</rim:permissions> 

在其他的信息...这里是什么在我的plugins.xml:

<plugins> 
    <plugin name="App"   value="org.apache.cordova.app.App"/> 
    <plugin name="Device"   value="org.apache.cordova.device.Device"/> 
    <plugin name="Camera"   value="org.apache.cordova.camera.Camera"/> 
    <plugin name="NetworkStatus" value="org.apache.cordova.network.Network"/> 
    <plugin name="Notification" value="org.apache.cordova.notification.Notification"/> 
    <plugin name="Accelerometer" value="org.apache.cordova.accelerometer.Accelerometer"/> 
    <plugin name="Geolocation" value="org.apache.cordova.geolocation.Geolocation"/> 
    <plugin name="File"   value="org.apache.cordova.file.FileManager"/> 
    <plugin name="FileTransfer" value="org.apache.cordova.http.FileTransfer"/> 
    <plugin name="Contacts"  value="org.apache.cordova.pim.Contact"/> 
    <plugin name="Capture"  value="org.apache.cordova.capture.MediaCapture"/> 
    <plugin name="Battery"  value="org.apache.cordova.battery.Battery"/> 
    <plugin name="Media"   value="org.apache.cordova.media.Media"/> 
    <plugin name="ChildBrowser" value="org.apache.cordova.plugins.childbrowser.ChildBrowser"/> 
</plugins> 

我怀疑这只是一个简单的问题(就像我在xml中访问权限时做错了什么),但在尝试了各种不同的事情并在互联网上搜索之后,我很难过......

任何帮助,将不胜感激。

回答

2

你的代码看起来对我来说是正确的。

如果您有BlackBerry连接到USB并在“USB Drive”(USB驱动器)屏幕出现提示时输入了设备密码,那么您将启用“大容量媒体/存储模式”。这会将文件系统锁定到USB并阻止您的应用访问它。我希望您在尝试调用fileSystem.root.getDirectory时会看到一个错误。

+0

这是很好的知道......在模拟器中运行怎么样?我在那里遇到同样的问题。 – mason81 2012-08-21 18:47:15

+0

我会接受这个答案。它不能解决我的问题,但我确实发现BlackBerry设备不支持“传输”选项,因此,无论如何,我是否可以读取这些文件并不重要,因为我只是将其用作更新的手段它们是动态的,无论如何,我显然无法对Cordova/Phonegap进行处理。感谢您花时间回答并提供有用的提示。 – mason81 2012-08-24 18:45:48

2

我对这个也有很多乐趣。我相信这种错误发生的原因有很多。

然而,对于我来说,当连接USB电缆时,Blackberry将带走本地存储和SD卡。 开发时不太有用,一些有意义的错误代码会帮助BB!

希望这可以帮助别人。

1

对于blackberry10,科尔多瓦/ WebWorks的就试试这个:

window.webkitRequestFileSystem(window.PERSISTENT, 5*1024*1024, onSuccess, null); 

而不是科尔多瓦的实现:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 5*1024*1024, onSuccess, null); 

这工作对我来说,现在我有一个条件来触发以上任何一个对于黑莓/其他人。希望它适合你们,就像它为我做的那样。

干杯