/** * Package Proecssdialog dialog box * */public class Loaddialog extends ProgressDialog {private string title = Progress Dialog;p Rivate String Message = "Load data ....";p ublic Loaddialog (context context, int theme) {Super (context, theme);} /** * Create dialog box with default title and content * @param context */public Loaddialog (context) {super (context); InitDialog ();} /** * Create a dialog box with the specified title and content * @param context * @param title * @param message */public loaddialog (context context,string title,st Ring message) {super (context); if (title! = null) {this.title = title;} if (message! = null) {this.message = message;} InitDialog ();} /** * Initialize the dialog box parameters, the default dialog cannot be canceled */public void InitDialog () {settitle (title); setmessage (message); Setprogressstyle ( Progressdialog.style_spinner); setcancelable (false);} /** * Opens the dialog box, sets the callback method, passes the class template that needs to execute the business method, the method name and the parameter list * @param the callback callback method, callback after the dialog closes, and gets the returned data * @param ServiceClass class template that executes the business method * @param method name * @param params execution Business method parameter list */public void execute (Callback callback,class serviceclass,string m Ethod,object. Params) {SUPER.Show (); Serviceaysntask task = new Serviceaysntask (Callback,serviceclass,method); Task.execute (params);} /** * Callback Method interface * */public interface callback{public void GetResult (map map);} /** * Thread class communicating with remote service * @author BDK * Asynctask Asynchronous Task */private class Serviceaysntask extends ASYNCTASK<OBJECT,OBJECT,MAP&G T {Private Class serviceclass;private String method;private Callback callback;public serviceaysntask (Callback Callback, Class serviceclass,string method) {this.callback = Callback;this.serviceclass = Serviceclass;this.method = method;} @Overrideprotected map Doinbackground (Object ... params) {Map Resultmap = null;try {Object obj = serviceclass.newinstance ( );//Create class Template Object class [] Paramtypes = new Class[params.length];for (int i = 0; i < paramtypes.length; i++) {Paramtypes[i] = Params[i].getclass ();} According to the class template get method M = Serviceclass.getmethod (method, paramtypes); resultmap = (Map) m.invoke (obj, params);} catch (Exception e) {e.printstacktrace ();} LoadDialog.this.cancel (); return resultmap;} @Overrideprotected void OnPostExecute (Map result) {Super.onpostexecute (result); if (result = = null) {Toast.maketext ( LoadDialog.this.getContext (), "Network communication exception", Toast.length_long). Show (); return;} Callback.getresult (result);}}}