Android Question [Q]FTP Crashing Issue

Tyler

Member
Licensed User
Hey guys! I've been messing with the app "aide" and have written the following code that is crashing the app for some reason:


B4X:
    public void startClick(View Button)
    {
      

        boolean status = false;
        try {
            FTPClient mFtpClient = new FTPClient();
            mFtpClient.setConnectTimeout(10 * 1000);
            mFtpClient.connect(InetAddress.getByName("ftp.drivehq.com:21"));
            status = mFtpClient.login("USERNAME", "PASSWORD");

            if (FTPReply.isPositiveCompletion(mFtpClient.getReplyCode())) {
                mFtpClient.setFileType(FTP.ASCII_FILE_TYPE);
                mFtpClient.enterLocalPassiveMode();
              
                Toast huh = Toast.makeText(getApplicationContext(), "testttt", 5000);
                huh.show();
                mFtpClient.logout();
                mFtpClient.disconnect();


            }
        }
        catch(SocketException e)
        {
            e.printStackTrace();
        }
      
        catch(UnknownHostException e)
        {
            e.printStackTrace();
        }
      
        catch(IOException e)
        {
            e.printStackTrace();
        }
  
    }
 

Tyler

Member
Licensed User
B4A uses a bunch of libraries to convert code written in BASIC to Java. While we write in BASIC, B4A is almost entirely made up of Java.
 

Tyler

Member
Licensed User
I understand that. Are you here to help or to point our incredibly obvious things?
 

DonManfred

Expert
Licensed User
Are you here to help or to point our incredibly obvious things?
If you show me your B4A-code i can try to help. But i can not help with java-code your wrote. I dont know java. And because of this i did not start developing with Eclipse.

If you show your B4A-Code and post the errors you get in the log we can try to help

As far as i can READ your java code; for connecting to an ftp you can use the Net-Library in B4A. See ftp-tutorial.
 

Tyler

Member
Licensed User
If you don't know Java, why are you even replying? The only reason I ask here is because I'm already somewhat familiar with this community and know many members have extensive knowledge of Java. Plus my code IS for Android, so I don't think it's too big of a leap to assume someone here has some knowledge of how to get this very basic code to work. Honestly, I just CBA to make an account elsewhere:p or try to navigate their F-ing terrible forum UI's.

Also, I used jk2ssh for b4a and it worked like a charm:)

And FYI: maybe this doesn't apply elsewhere but back when I was using unity, Java and C# are almost the exact same. I could Ctrl-F and replace certain lines to convert the code very quickly between the two languages.
 
Last edited:

Tyler

Member
Licensed User
The reason I'm learning java is to make my own libraries for B4A for new stuff in Lollipop. I guess I'll go ask stackoverflow. Thanks anyways.
 
Top