Wednesday 21 August 2013

AsyncTask Android ProgressBar not showing [Possible Duplicate]

AsyncTask Android ProgressBar not showing [Possible Duplicate]

first of all I want to say that i know there a couple of similar question
on S.O but non of them answered my question...
First of all let me show you my code:
I have a fragment that when it loads it sends a request to a server,
parses the JSON the server returns and then returns the parsed JSON as an
object.
I initialize a progress bar in the onCreateView method:
bar = (ProgressBar) mainView.findViewById(R.id.progressBar);
and then I create an instance of the Asynctask extended class:
PolisotAsyncInfo task = new PolisotAsyncInfo();
and then call the execute method and after that call the get function:"
task.execute(new
PolisotAsyncParameter(ClientMainActivity.mToken,ClientMainActivity.mUserID));
Object o = task.get();
I think this is what i'm doing wrong but not sure, i need to use the get()
method because i need the data that the doInBackround returns....
at this point the compiler goes to the onPreExecute method there i set the
bar to visible:
bar.setVisibility(View.VISIBLE);
after the the doInBackround methods run and does all kind of stuff that is
not relevant
and then the onPostExecute method is called there I set the bar to GONE:
bar.setVisibility(View.GONE);
Any help would be appreciated guys, I'm kind of lost here...
thanks!!

No comments:

Post a Comment