i want to get Ftp folders list from server using AsyncTask and return folders names ArrayList to main class and update spinner adapter.
In main class i got spinner with
Implement a listener passing ArrayList and use this listener for returning your ArrayList.
public interface TaskListener {
public void onSuccess(ArrayList result);
}
While invoking your async task for operation execution create an instance of TaskListener as follows:
TaskListener listener = new TaskListener() {
@Override
public void onSuccess(ArrayList result) {
// Your result will come here
}
};
Pass this listenerobject as a parameter to the async task constructor. And create a global instance of TaskListener in the async task itself. Assign the TaskListener parameter in the constructor to the global instance.
Then in the onPostExecute of the async task class:
protected ArrayList[] onPostExecute(ArrayList... result) {
this.taskListenerGlobalInstance(result); // this will invoke the call back method
}