android - Calling AsyncTask from the Activity -


for code snippet( have excluded doinbackground(), postexecute() etc. ) how should pass activity parameter while calling async task checkserver activity?

public class checkserver  extends activity{      @override     protected void oncreate(bundle savedinstancestate) {         // todo auto-generated method stub         super.oncreate(savedinstancestate);       httpticket ticket= new httpticket(); //how line done? param should passed?        }      @suppresswarnings("unused")     private class httpticket extends asynctask<string, string, string>     {         private activity activity;         private progressdialog dialog;           public httpticket(activity activity) {              this.activity = activity;           } 

you can sipmly do

httpticket mhttpticket = new httpticket(this);  mhttpticket.execute();  

you delete constructor, , pass onpreexecute param. give in execute(this);


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -