android - ProgressDialog freezes when trying to run a service with an asynctask -
i have code inside asynctask:
@override protected void onpreexecute() { waitdialog = new progressdialog(context); waitdialog.settitle(r.string.wait_title); waitdialog.setmessage(context.getstring(r.string.wait_body)); waitdialog.setindeterminate(true); waitdialog.show(); } @override protected boolean doinbackground(void... unused) { intent serviceintent = new intent(context, publisherservice.class); savesettings(false); startservice(serviceintent); return serviceisrunning(); }
the dialog shows while service starting (and takes few seconds) progressdialog frozen. if use simple systemclock.sleep()
inside doinbackground()
call works fine.
can tell me why happening , how solve issue?
thanks
you should not start services threads or asynctasks. service start own thread , perform work there. or it's possible bind service in onpreexecute() , call methods doinbackground. read local service sample here http://developer.android.com/reference/android/app/service.html
Comments
Post a Comment