Wednesday, 15 January 2014

android - AsyncTask onPostExecute call from outside the AsyncTask -



android - AsyncTask onPostExecute call from outside the AsyncTask -

i want utilize same asynctask in different places on app , want different onpostexecute each one. it's possible phone call them oncreate method instead of asynctask class?

something like:

new asynctcp.execute() onpostexecute(){ //do stuff }

just create asynctask no onpostexecute method overridden

public class yourtask extends asynctask<whatever, whatever, whatever> { @override protected whatever doinbackground(whatever... whatever) { // whatever homecoming whatever; } }

and when want different implementations of onpostexecute, create anonymous task or descendant class , utilize it

task = new yourtask() { @override protected void onpostexcecute(whatever result) { //whatever } }; task.execute();

or better

public class yourtaskanother extends yourtask { // override onpostexecute here @override protected void onpostexcecute(whatever result) { //whatever } } task = new yourtaskanother(); task.execute();

android android-asynctask

No comments:

Post a Comment