[code]
package com.bignerdranch.android.runtracker;
import org.apache.commons.net.ftp.*;
import android.util.Log;
public class DataSend {
public FTPClient mFTPClient = null;
public boolean ftpConnect(String host, String username, String password, int port)
{
try {
mFTPClient = new FTPClient();
// connecting to the host
mFTPClient.connect(host, port);
// now check the reply code, if positive mean connection success
if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
// login using username & password
boolean status = mFTPClient.login(username, password);
mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
mFTPClient.enterLocalPassiveMode();
return status;
}
} catch(Exception e) {
/*Log.d(TAG, "Error: could not connect to host " + host );*/
}
return false;
}
}
[/code]
[code]
mSendButton =(Button)view.findViewById(R.id.run_sendButton);
mSendButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DataSend a = new DataSend();
a.ftpConnect("192.168.0.4", "id123", "123", 21);
}
});
[/code]
첫번쨰 코드는 FTP접속을 하기위한 코드이고
두번쨰 올린 코드는 버튼을 눌렀을때 위의 코드를 실행해주기위해
객체를 만들고 그안의 메서드를 실행시킨 코드입니다.
분명 에러도없고 실행도 되는데 어플리케이션에서 해당버튼을 누르면
아무 반응도없고 FTP서버상태를 봐도 접속했다는 메시지가 전혀뜨지 않는데
어디가 문제인거죠???....