开发者

Cannot connect to FTP on Gingerbread

I recently noticed that when trying to run my application on the Gingerbread emulation, that FTP broke. I am currently using the apache commons external library for FTP support, but for some reason it works on every other Android OS except 2.3 (Gingerbread)

Here is my FTP code

FTPClient ftp = new FTPClient();
ftp.connect(SERVER);
ftp.login("anonymous", "anonymous");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();

InputStream is = ftp.retrieveFileStream("file.txt");
byte[] data = new byte[1024];

fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
int x = 0;
while((x=is.read(data,0,1024))>=0){
    fos.write(data,0,x);
}
fos.flush();
fos.close();
ftp.logout();
ftp.disconnect();

As I said, this is tested and works on 1.6, 2.1 and 2.2, but not 2.3. I've tried all day to figure out why and how to fix it but I can't find any solution.

I was therefore wondering if anybody have experience with FTP and Gingerbread and if you might be so nice to guide me in the right direction.

Thanks.开发者_JAVA百科


I don't know what is causing the problem, but I found out that FTP on Android 2.3 does work, but not in emulation.

The moment I tried my code on my cell phone, it worked like it had on all previous versions of Android.

Thanks for all the help!


The first thing I would check is if you have the correct permissions, if that is the case check Logcat for any exceptions. If you have any please post them here or via a pastebin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜