You can write all the FTP code in a service.
There are several possible ways to communicate between the activity and the service.
You can use process global variables to hold the information about the task and call StartService to start the service. The service should check the variables and then run the task.