• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps org.apache.commons.net.ftp.FTPClient.storeFile freezing interaction and animations

thaylin79

Lurker
Mar 2, 2012
2
1
I'm using org.apache.commons.net.ftp.FTPClient to communicate with an ftp server via an android app I'm making that records video and then uploads it to the ftp server. Everything is fine until I call storeFile at which point the app prevents any interaction until the uploading is completed. Is there any way around this? I'm currently developing for API lvl 12. My set up is as follows I have a class that calls a service in the background to handle recording of the video as well as the ftp setup. In the FTP class I have any of my fptclient interaction within asynctasks. Here is my method for uploading the file:
Code:
public boolean upload(String srcFilePath, String desFileName, String desDirectory)
{
    if(!isLoggedIn())
    {
        return false;
    }
    boolean status = false;
    try
    {
        status = new AsyncTask<String, Void, Boolean>(){
            @Override
            protected Boolean doInBackground(String... args) {
                boolean status = false;
                try {
                    String srcFilePath = args[0];
                    String desFileName = args[1];
                    String desDirectory = args[2];
                    FileInputStream srcFileStream = new FileInputStream(srcFilePath);

                    // change working directory to the destination directory
                    if (changeDirectory(desDirectory,true)) {
                        status = mFTPClient.storeFile(desFileName, srcFileStream);
                    }
                    srcFileStream.close();
                    return status;
                } catch (Exception e) {
                    Log.d(TAG, "upload failed");
                    e.printStackTrace();
                    return false;
                }
            }
         }.execute(srcFilePath, desFileName, desDirectory).get();
    } catch (InterruptedException e)
    {
        e.printStackTrace();
        return status;
    } catch (ExecutionException e)
    {
        e.printStackTrace();
        return status;
    }
    return status;

}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones