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
-- PSEUDO CODE --
Create a custom interface
as followed:
public interface IAsyncTask {
void IAmFinished(ArrayList<Object> arrayList);
}
Add a constructor to your AsyncTask
:
private IAsyncTask asyncTaskListener;
public MyAsyncTask(IAsyncTask asyncTaskListener){
this.asyncTaskListener = asyncTaskListener;
}
In your PostExecute
of the AsyncTask
:
public void onPostExecute(List<String> list) {
asyncTaskListener.IAmFinished(list);
}
In your Activity
that starts your AsyncTask
:
MyAsyncTask asyncTask = new MyAsyncTask(this);
asyncTask.execute(..);
Implement the interface:
public class MyActivity implements IAsyncTask
Implement the method:
public void IAmFinished(ArrayList<Object> list){
// Do whatever you want with your returned object
}