Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Mahmoud Tokura789 Points
How do i set INDETERMINATE_PROGRESS
How do i set INDETERMINATE_PROGRESS for this activity in case of slow network so the user knows something is happening. If the network is slow to retrieve, the user might thing the app has crashed or the phone has frozen.
I need to set INDETERMINATE_PROGRESS.
Daniel Hartin18,106 Points
What i have done in my apps for network connections that require some form of data returned is set the xml layout file to be a relativeLayout and then place a progress bar at the end of the xml file which covers the entire screen, then you can simply refer to this this in your activity like you would any other view and set it by doing something like
ProgressBar mProgressBar = (ProgressBar) findViewById(R.id.progressbar1); mProgressBar.setVisibility(View.VISIBLE); //To turn on mProgressBar.setVisibility(View.INVISIBLE); to turn off
The reason I would use a progressBar that covers the screen is that I assume as your are recovering images (guessing based on question) the user can't really continue until the images are found so a small progress bar in the notification bar may be missed. If you definitely want it in the notification bar however use the following
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); //put this before the call to setContentView() setSupportProgressBarIndeterminateVisibility(true); //to turn on setSupportProgressBarIndeterminateVisibility(false); //to turn off
Obviously for both of the above you have to turn them on and off manually when you start you aSyncTask and when the data is returned.
Hope this helps