would it be an option to create the CheckFtpTask object once and then reuse it? Or will that give me side effects?
No, there will be side-effects. Quoting the docs Threading Rules:
The task can be executed only once (an exception will be thrown if a second execution is attempted.)
You will just need to create a separate instance of the task each time you want to run it.
And I'm not sure why you need the Runnable
or Handler
. AsyncTask
has methods that run on the UI Thread
(all but doInBackground()
, actually) if you need to update the UI
.
Check this answer if you need a callback to update the UI
when the task has finished.