0

当我连接到我的在线 ftp 服务器 (ftp.spicy-software.com) 时,它不起作用,没有错误或崩溃。只是一个空白的布局。但是当我连接到我的本地 ftp 服务器时,它可以工作并且会显示图片。为什么??

我正在连接到运行良好的本地 ftp 服务器(本地 IP:192.168.99.105),图片将显示在 gridview 中:

在此处输入图像描述

    new FtpTask().execute();

    private class FtpTask extends AsyncTask<Void, Void, FTPClient> {
     protected FTPClient doInBackground(Void... args) {
         //connectFTP("192.168.99.105", "Username", "Password", 21);
         connectFTP("ftp.spicy-software.com", "USername1", "Passweord", 21);
        return null;

     }

     protected void onPostExecute(FTPClient result) {
         Log.v("FTPTask","FTP connection complete");
     }
    }

connectFTP() 函数:

    public void connectFTP(String host, String username, String password, int port){

    try {
        FTPClient ftpClient = new FTPClient();
        ftpClient.connect(host, port);
        ftpClient.enterLocalPassiveMode();
        ftpClient.login(username, password);
        ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
        ftpClient.changeWorkingDirectory("GetThePicture/pictures/");
        Log.v("FTP STATUS: ",ftpClient.getStatus());


        FTPFile[] files = ftpClient.listFiles();

        for (FTPFile file : files) {
            Log.v("File: ", "http://spicy-software.com/GetThePicture/pictures/"+file.getName());
            imageUrls.add("http://www.spicy-software.com/GetThePicture/pictures/"+file.getName());
            imageNames.add(file.getName());
        }

        Log.v("FILE_1: ", imageUrls.get(1));
    } catch (Exception e) {
        Log.v("Error", ""+e);
        e.printStackTrace();
    }
}

但是当我尝试连接到 ftp.spicy-software.com 在线 ftp 服务器时,它不起作用:

日志猫:

05-01 15:31:50.280: D/AbsListView(2136): Get MotionRecognitionManager

05-01 15:31:50.345: D/libEGL(2136): loaded /system/lib/egl/libEGL_mali.so
05-01 15:31:50.350: D/libEGL(2136): loaded /system/lib/egl/libGLESv1_CM_mali.so
05-01 15:31:50.350: D/libEGL(2136): loaded /system/lib/egl/libGLESv2_mali.so
05-01 15:31:50.355: D/(2136): Device driver API match
05-01 15:31:50.355: D/(2136): Device driver API version: 10
05-01 15:31:50.355: D/(2136): User space API version: 10 
05-01 15:31:50.355: D/(2136): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
05-01 15:31:50.390: D/OpenGLRenderer(2136): Enabling debug mode 0
05-01 15:31:53.605: V/FTP STATUS:(2136): 211-Status of 'ftp.easyname.eu'

05-01 15:31:53.605: V/FTP STATUS:(2136): 211-Connected from 109.164.221.167 (109.164.221.167)

05-01 15:31:53.605: V/FTP STATUS:(2136): 211-Logged in as 35221ftp1

05-01 15:31:53.605: V/FTP STATUS:(2136): 211-TYPE: BINARY, STRUcture: File, Mode: Stream

05-01 15:31:53.605: V/FTP STATUS:(2136): 211-No data connection

05-01 15:31:53.605: V/FTP STATUS:(2136): 211 End of status

05-01 15:31:53.910: W/dalvikvm(2136): dvmFindClassByName rejecting 'UNIX Type: L8'
05-01 15:31:55.285: D/dalvikvm(2136): GC_CONCURRENT freed 167K, 10% free 12399K/13703K, paused 4ms+2ms, total 24ms
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/1.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/2.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/3.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/4.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/5.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/6.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/7.jpg
05-01 15:31:55.775: V/File:(2136): http://spicy-software.com/GetThePicture/pictures/8.jpg
05-01 15:31:55.775: V/FILE_1:(2136): http://www.spicy-software.com/GetThePicture/pictures/2.jpg
05-01 15:31:55.780: V/FTPTask(2136): FTP connection complete
4

1 回答 1

0

问题是 AsyncTask 不在主线程中运行,代码太快了!因此,它尝试在 asynctask 完成之前使用 imageloader 加载这些图像......

于 2013-05-03T06:04:11.200 回答