Android - Showing progress dialog in a separate class which extends AsyncTask -


i have class called myapi, used getting information server db. class has several classes used individual information, example getcourseinformation, login, register, , many more.

it worked until point realized need progressdialog. indeterminate progressdialog exact.

tried doing :

progressdialog progressdialog;     context context;      public myapi(context context)     {         this.context= context;     }     public myapi()     {      } 

to context of class myapi called.

and below how use in 1 of class.

public class login extends asynctask<mylogin, string, string>{      @override     protected void onpreexecute() {         progressdialog = new progressdialog(context);         progressdialog.setmessage("loading...");         progressdialog.setindeterminate(true);         progressdialog.setprogressstyle(progressdialog.style_spinner);         progressdialog.setcancelable(true);         progressdialog.show();     } ... } 

but doesn't work. says unable add window -- token null not application

debugged it, , see context there.. shouldn't that.. guide much appreciated!

instead of use context, try use activity

@override     protected void onpreexecute() {         progressdialog = new progressdialog(getactivity());         progressdialog.setmessage("loading...");         progressdialog.setindeterminate(true);         progressdialog.setprogressstyle(progressdialog.style_spinner);         progressdialog.setcancelable(true);         progressdialog.show();     } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -