Monday, 15 September 2014

progress dialog is not working while calling new MyAsyncTask().execute().get() Android -



progress dialog is not working while calling new MyAsyncTask().execute().get() Android -

how show progress dialog on onpreexecute() of asynctask android below code here in onpreexecute() method progress dialog not showing on ui thread

//calling asynctask

try { new xyz().execute(employeeid, password).get(); } grab (interruptedexception e1) { // todo auto-generated grab block e1.printstacktrace(); } grab (executionexception e1) { // todo auto-generated grab block e1.printstacktrace(); } class xyz extends asynctask<string, integer, void> { progressdialog simplewaitdialog; @override protected void onpreexecute() { simplewaitdialog = new progressdialog(treeviewlistdemo.this); system.out.println("fgfdgfgfgf"+simplewaitdialog); simplewaitdialog.setmessage("loading..."); simplewaitdialog.setindeterminate(true); simplewaitdialog.setcancelable(true); simplewaitdialog.show(); } @suppresswarnings("unchecked") @override protected void doinbackground(string... params) { string username = params[0]; string password = params[1]; // code perfoming soap web services working fine , getting info server side homecoming null; } }

you calling get(), presumably ui thread. documentation, get() method:

waits if necessary computation complete, , retrieves result.

this means block ui thread cannot show progress dialog. think want replace phone call get() execute()

android android-intent android-activity android-asynctask

No comments:

Post a Comment