This seems like it should be a simple question, but for some reason I haven't come up with an obvious answer yet:
I have a horizontal progress bar displayed by my app while it does some work in the background. There are a finite amount of steps in this process, so I display actual progress rather than using an indeterminate progress bar.
However, there are occasionally steps in this process that take a very long time, so the progress bar is stationary for a while.
I could update the progress at a finer resolution, but I'd rather have the progress bar "pulse" or show some other constant animation just so that the user can see it is still working. I assumed Android would have this built in without me having to do much work, since it's such a common UI feature, but I can only seem to get this to work if I use an indeterminate progress bar.
Is there an easy way to do this, or do I have to write some kind of custom animation?
Related
I have a vocab building app with different vocab categories displayed in a list view. I want to have a circular progress indicator for each category that shows how familiar the user is with the vocab stored in it. I know that Android has a built-in Progress Bar. The design is what I'm looking for, however, it appears that the progress bar is running continuously by default. Whereas in my case, I just want it to be static and updated only when the activity that displayed the category items are (re)opened. So to summarize again, the main difference is that the progress bar I'm looking for isn't dependent on a process that is currently running but instead from an SQLite database where I stored information on how familiar the user is with each vocab.
I have searched online and I wasn't able to solve this problem since progress bar is usually implied to be dependent on a running process.
Thank you so much for any help in advance!
The Android ProgressBar is designed to show the progress of a process, yes, you are correct. They can be either determinate (they go from beginning to end... like a BAR), or indeterminate (they go round and round... like a CIRCLE). Circular progressbars are indeterminate and therefore do not communicate progress per-se, only that there is something in the process of "progressing" and not finished yet.
You say you want to use this widget to communicate to the user what their PERSONAL progress is in a given area.
If you insist on using the ProgressBar widget, then you would need to use a determinate one (horizontal)...
But you do not need the progress bar widget... just make your own indicator or some kind... like
1) Using views/animations, like create a view space and tell it to fill 60%, 20%, whatever...
2) make your own set of bitmap files (say, 5 of them representing 0%, 25%, 50%, 75%, 100% on a circular progress bar)... and swap them out depending on the users progress.
I have searched everywhere and read the official doc of Google. But I still don't see the difference between them.
When should we use ProgressBar and when should we use ProgressDialog?
ProgressBar:
ProgressDialog:
The ProgressBar is a View, ProgressDialog is a Dialog.
While the answers here are informative, none really address the question.
Use a ProgressDialog when you want to prevent the user from
interacting with the application while waiting. The Dialog aspect
freezes the user from doing anything until it is dismissed. Note how the UI behind the ProgressDialog is grayed-out and inaccessible.
Use a ProgressBar to indicate that something in your app is still
waiting (loading, thinking, etc.) while the user may still interact with
other parts. In this image, the user can still fill out forms while waiting for the gps to respond.
(Thanks to Johnny S for the image of the ProgressDialog.)
ProgressBar is a View (like TextView, ImageView, Button, etc..), which can be used in your layout to show some progress.
ProgressDialog is a Dialog with 'built-in' ProgressBar. Dialogs can be used to make user wait while something is being computed. ProgressDialog makes it easier to show progress of your computation in dialog.
In addition to the differences pointed out in the rest of answers, you should take into account the following recommendation from Dialogs # Android Developer:
Avoid ProgressDialog
Android includes another dialog class called ProgressDialog that shows
a dialog with a progress bar. However, if you need to indicate loading
or indeterminate progress, you should instead follow the design
guidelines for Progress & Activity and use a ProgressBar in your
layout.
It may be also usefull to consider the following answers:
https://stackoverflow.com/a/12559601/2482894
How to avoid ProgressDialog in Android
When your iterations is countable (doing operations in loop, executing code x times etc.) use ProgressBar, if task is not countable status (like invoking web service) use ProgressDialog
From the android documentation
ProgressBar:Visual indicator of progress in some operation. Displays a bar to the user representing how far the operation has
progressed; the application can change the amount of progress
(modifying the length of the bar) as it moves forward. There is also a
secondary progress displayable on a progress bar which is useful for
displaying intermediate progress, such as the buffer level during a
streaming playback progress bar.
ProgressDialog:A dialog showing a progress indicator and an optional
text message or view. Only a text message or a view can be used at the
same time.
Maybe my English is poor but I really cannot figure out what the "indeterminate" means in this context:
Android Development → ProgressDialog.isIndeterminate()
It means the "loading amount" is not measured.
From wiktionary:
Indeterminate: Not accurately determined or determinable.
It basically just means you're unsure how long the action will take so you cannot say for example something is 50% done.
This normally just means the progress will be displayed as a constantly moving loading bar rather than a percentage or the like.
Basically when setProgressStyle(ProgressDialoge.STYLE_SPINNER) is taken then setIndeterminate() will be true because a circle(Spinner) will rotate, which shows that "do not know how much time it is going to take". When take ProgressStyle(ProgressDialoge.STYLE_HORIZANTAL) we will take setIndeterminate() as false since it take a value/percentage bar like how much percentage it was completed with setProgress(value).
In simple language we can say when the amount is not determined means we don't know how much it gonna be to be completed or loaded fully..!!
Change the indeterminate mode for this ProgressDialog. In
indeterminate mode, the progress is ignored and the dialog shows an
infinite animation instead.
Note: A ProgressDialog with style STYLE_SPINNER is always
indeterminate and will ignore this setting.
Blockquote
For illustration, the progress animation keep loading from left to right and then repeat automatically without user interaction(which setProgress) when indeterminate set to true.
Reference here.
I have a WidgetProvider which is around for milliseconds. It takes in an intent, and it kicks off a service which takes maybe noticeable time. I wanted to display something to the user during this delay like a progress bar that will block user, but the BroadcastReceiver/WidgetProvider seems like the wrong place to start up a progress bar. Where should I issue the Progress Bar in this case? Service maybe? but service might not be part of UI at all?
Where should I issue the Progress Bar in this case?
From a UI perspective, your only choice is to have it in the app widget itself. ProgressBar is one of the valid widgets to have in an app widget layout.
In terms of who updates the RemoteViews of your app widget to display/update/remove the ProgressBar, that is probably your Service in whatever background thread you are using for the "noticeable time".
Have you tried putting a progress bar in the notifications pull down? Doing something like the market displays when you're downloading an app should work really well, and execute in the background well.
Use can use AsynTask to display progress bar.
I have already posted my query here, but unfortunately, not getting the required support for this simple query.
I am using a progressbar widget in my application to show the download progress.
In the current state, I am able to manually move the slider back and forth while download is progressing. How can I prevent the manual moving of progressbar, instead it works only based on
progressbar.setProgress(progressbar.getProgress() + 1024); -- currently this works perfect, but I need to prevent the manual moving of progressbar during download.
There is example code on the Android developers website:
https://developer.android.com/reference/android/widget/ProgressBar.html
Have you followed that? I doubt the progress bar is scrollable by default, it would be a seek bar then