Naruto
Naruto

Reputation: 9634

Best way to implement loading screen in android

i am making lot of HTTP calls in my applications & switches between the views, now i'm handling the Http calls in a thread, but i want to make user to wait when the http request in progress. How to do this?. I just need to show a wait cursor or loading string.

Upvotes: 1

Views: 2391

Answers (3)

Yash Krishnan
Yash Krishnan

Reputation: 2785

May be this will helpful. You have to make a background operation using thread concept like AsyncTask. Using this you can hide the actual work from the UI part. And AsyncTask will get unallocated after your operations are completed.

  • Create a subclass of AsyncTask
  • Use AsyncTask to do background work
  • Call onPreExecute() to initialize task
  • Use a progressbar with setIndeterminate(true) to enable the indeterminate mode
  • Call onProgressUpdate() to animate your progressbar to let the user know some work is being done
  • Use incrementProgressBy() for increment progressbar content by a specific value
  • Call doInBackground()and do the background work here
  • Catch an InterruptedException object to find end of background operation
  • Call onPostExecute() to denote the end of operation and show the result

Upvotes: 0

Vitor M. Barbosa
Vitor M. Barbosa

Reputation: 3646

I find the name a bit misleading, but you should show a ProgressBar while background operations conclude.

Upvotes: 1

MSA
MSA

Reputation: 2482

You can use a ProgressDialog whit a Handler.

Android Progress Dialog Example

Android's indeterminate ProgressDialog tutorial

Cheers

Upvotes: 3

Related Questions