You can take a look at AsynTask. Among others, there are three methods that can serve your requirement.
onPreExecute, onPostExetcute and doInBackground;
run the run dialog in onPreExecute reject the run dialog in onPostExetcute you connect to doInBackground.
Hope this serves your purpose.
Umesh source
share