hi all,

I am developing an application which require accessing  a website for
data, and will show that data on device. I wants to fetch data from
Internet in background and show ProgressDialog or ProgressBar on
device and when application receive response from server  app will
dismiss the dialog or bar and will show data .

For this i am using AsyncTask -

code for AsyncTask is as follows--

ServerTask extends AsyncTask{
        @Override
        protected void onPreExecute() {
                dialogAccessingSpurstone = new ProgressDialog(ctx);
                dialogAccessingSpurstone.setMessage(shownOnProgressDialog);
                dialogAccessingSpurstone.show();
        }

        @Override
        protected ServerResponse doInBackground(String... urlArray) {

                String urlString = urlArray[0];
                HttpResponse serverResponseObject = null;

                //finding HttpResponse

                return serverResponseObject;

        }//end of doInBackground

        @Override
        protected void onPostExecute(HttpResponse serverResponseObject){
                dialogAccessingSpurstone.dismiss();

        }
}


and calling this code as follows--

ServerTask serverTaskObject = new ServerTask();
serverTaskObject.execute();
HttpResponse response = serverTaskObject.get();

//performing operation on response

but ProgressDialog is not shown.(I guess the reason for it is the
thread is not complete and android invalidate only when thread has
completed).

My Questions --
1- If my guess is right ? If yes then how I should implement it?
2- If there any other better way to do this?

thanks


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to