(Android Firefox插件)需要从Data.txt读取
我是Android firefox插件的初学者。我从路径(/mnt/sdcard/)中读取file.txt有一些困难。我知道这对于桌面是可能的,但我不知道对于android是否可能。我花了两天时间,但没用。这是我的bootstrap.js代码(Android Firefox插件)需要从Data.txt读取,android,firefox,firefox-addon,Android,Firefox,Firefox Addon,我是Android firefox插件的初学者。我从路径(/mnt/sdcard/)中读取file.txt有一些困难。我知道这对于桌面是可能的,但我不知道对于android是否可能。我花了两天时间,但没用。这是我的bootstrap.js代码 var file = Components.classes["@mozilla.org/file/directory_service;1"]. getService(Components.interfaces.nsIProp
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties)
.get("/mnt/sdcard/", Components.interfaces.nsIFile);
file.append("NewDir");
if( !file.exists() || !file.isDirectory() ) {
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
}
this.log_file=file.path+"/Data.txt";
var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance( Components.interfaces.nsIFileInputStream );
is.init( file,0x01, 00004, null);
var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance( Components.interfaces.nsIFileInputStream );
is.init( file,0x01, 00004, null);
var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance( Components.interfaces.nsIScriptableInputStream );
sis.init( is );
var output = sis.read( sis.available() );
代码不起作用如果您将问题中提供的内容粘贴到bootstrap.js中,那么它在普通Firefox上有效吗?而不是Android版的Firefox?通常启动代码位于
startup()
函数中。这似乎不包括在函数中。这就是你在(桌面Firefox上的功能)代码中所使用的方式吗?谢谢@Makyen,我为android安装了startup()函数,但没有显示任何东西。请提供一个instal.rdf文件(和一个chrome.manifest,如果使用的话),这样我们就不必创建它们来测试这一点。基本上,如果有一个完整但最少的:足够的代码,这样我们就可以将它复制并粘贴到一个目录中并测试加载项,这会很有帮助。如果它不是您当前实际使用的,请尝试将问题复制和粘贴到一个新目录中,并验证它在桌面Firefox上工作,而在Android Firefox上不工作。基本上,除非有人处理了这个特定的问题,否则我们将不得不做一些测试。