Android - Function execute listener -


hey don't know if that's right way if how can it...

i have 1 abstact class asynctask

public abstract class a{   a(){     new task().execute();   }    public abstract void postaction();    private class task extends asynctask<string, string, string>{     protected string doinbackground(string... args)     {       //smth     }      protected void onpostexecute(string file_url){        postaction();     }   } } 

after have class extends class , overrides it's postaction() method:

public class b extends a{    b(){       //smth    }     postaction(){      //some action    } } 

in activity have instance of b , want perform action when postaction called... want function listener if possible , how can

class c extends activity{    public void oncreate(bundle savedinstance) {       super.oncreate(savedinstance);       //somethingggg happeiningggg    }     mylistener listener = new mylistener(){        onpostactioncalled()        {          //start activity or smt :d        }    }; } 

so have class json response(class a) , class b extends , overrides it's post method can want specific situation(expect different data or smth else nvm)

in activity want perform action when class b's post method called

i don't know if need listener or handler idk @ all....

stefan right, why complicate things?

see real simple example of threading:

public class myactivity extends activity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);           new mytask(new tasklistener() {          @override         public void finished(boolean result) {             // on main thread after task finishes          }     }).execute(); }  private interface tasklistener{     void finished(boolean result);       }  private class mytask extends asynctask<object, integer, boolean>{      private tasklistener mlistener;        public mytask(tasklistener mlistener) {         super();         this.mlistener = mlistener;     }      @override     protected boolean doinbackground(object... params) {         // long running background operation         return true;     }      @override     protected void onpostexecute(boolean result) {         mlistener.finished(result);         super.onpostexecute(result);     }        } 

}


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -