In the actual development process, we may have a lot of network requests where, this time we need some friendly hints, such as the progress of the dialog box
Ideally, we would write a global approach and then use the call directly on it.
Obviously, we should first think of writing a method directly in the application class of the project, and then doing progressdialog display and hiding, in this case, when we create the ProgressDialog object, It is natural to use the context object of the Getapplicationcontext, and then after it is run, it will burst. Windowmanager$badtokenexception the exception and forced the exit because we used the global application,
And dialog is only able to use activity as a parameter, and then we application the method inside, add an activity parameter can be, the problem is solved perfectly
/** * Display a dialog box */public static void Showprogressdialog (Context activitycontext,string msg) {progressdialog = new PROGRESSDI Alog (Activitycontext);p Rogressdialog.setprogressstyle (Progressdialog.style_spinner);p rogressdialog.setmessage ( msg);p rogressdialog.show ();}
Android implements the Global dialog box in the context issue. Windowmanager$badtokenexception Problem Solving