I have a bottom navigation view, and this view has 3 items 3 different fragments.
In my one fragment I am uploading a video file to server.
My question is :
When upload start I want to show uploading progress from my main activity like instagram doing.
How can do this ? any advice please
ProgressDialog pd=new ProgressDialog(context);
pd.setMessage("Your Message");
pd.show(); //Where you want to show PD
pd.dismiss();// where you want to Dismiss PD
Related
I want to show an AlertDialog inside an AsyncTask inside a Fragment, but just so that the AlertDialog is inside that Fragment, and not "blocking" the whole application, so that I can go through my tabs and on one fragment there is a AlertDialog blocking that Fragment.
progressDialog = ProgressDialog.show(getActivity(), "Please wait...", "Fetching data", true);
ProgressDialogs are generally frowned upon by the Android Design Guidelines and in your case they are definitely problematic due to their modal nature. It would be preferable to include a ProgressBar component in each of your fragments and show / hide (from your async task).
http://www.yogeshblogspot.com/android-progress-bar-indeterminate/
Is it possible to show progress bar when switching from activity to another.please help me
You will have to show the progress bar in the second activity because the first activity will be hidden and wouldn't show up anyway.
try this!!!!
ProgressDialog pd = new ProgressDialog(FirstActivity.this);
//use this before calling intent
pd.setMessage("Processing...");
pd.show();
//call this in onResume of firstActivity
pd.dismiss();
I've searched everywhere and I can't find a solution to this problem.
Basically I have a login screen and I'm trying to get a progress spinner to show up while it's logging in to the server (via a thread), and then dismiss it after the login is successful. It has to work while changing orientations.
I am using DialogFragment with the Android compatibility package to make a progress bar (can't find any documentation on it, only for basic\alert dialog) because showDialog() is deprecated now. Right now I just show a custom message box as a login spinner.
In Summary:
How can I set up a Progress spinner with DialogFragment.
How can I dismiss it in another thread after orientation changes.
For showing a progress spinner, just override DialogFragment.onCreateDialog() in your dialog fragment like this (no need for overriding onCreateView()):
#Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final ProgressDialog dialog = new ProgressDialog(getActivity());
//
dialog.setTitle(R.string.login_title);
dialog.setMessage(getString(R.string.login_message));
dialog.setIndeterminate(true);
dialog.setCancelable(false);
// etc...
return dialog;
}
As for dismissing that dialog fragment from somewhere else, you'll need to get a hold of FragmentManager (from inside your next FragmentActivity or Fragment) and call popBackStack() on it (if you don't do any other fragment transaction in the meantime).
If there's more steps/fragment transactions between your progress dialog fragment and the next activity, you'll probably need one of the other popBackStack(...) methods that take an ID or tag to pop everything up to your progress dialog fragment off the stack.
I know this is old question but I want to share much better solution for this
According to Android Development Protip:
"Stop using ProgressDialog,Inline indicators are your friend"
As Roman Nurik states:
This one's quick. Stop using ProgressDialog and other modal loading
indicators. They're extremely interruptive and annoying, especially
when:
You see one every time you switch tabs.
You can't Back out of them.
They say "Please wait." No thanks, I'd rather just uninstall.
Either show loading indicators inline with your content (e.g.
http://developer.android.com/training/animation/crossfade.html) or better yet, load small amounts of data in the
background so that you minimize the need to even show a loading
indicator.
More about progress & activity in the design guidelines.
In the android application that I am building, there are two Views, one below the other. The top one is a Login view, where I have a login form and a submit button, and there is a WebView below it.
I have implemented an AsyncTask when the login button is clicked and the request is sent to the server for login authentication. In the AsyncTask's onPreExecute() method, I create a ProgressDialog and show it. When there is a response from the server, and the login is authenticated, I dismiss the ProgressDialog in the onPostExecute() method of the AsyncTask.
The problem is that during the time the ProgressDialog is displayed, the entire screen is blackened out and does not respond to any touch. In the application that I am building, it is desired that the WebView below the Login view remains responsive to touches even when the ProgressDialog is being displayed (and the whole screen does not get blackened, only the Login view gets blackened).
Is there a way to do this? (All I need is a spinner kind of object to inform the user that some server authentication is taking place).
The following is some pieces of code from the application.
private class LoginProgressAsyncTask extends AsyncTask<Void, Void, String>{
private ProgressDialog dialog ;
protected void onPreExecute() {
dialog = ProgressDialog.show(context , null, "Verifying Login. Please wait...") ;
}
protected void onPostExecute(String result) {
if (dialog.isShowing()) {
dialog.dismiss();
}
}
Then why are you using a ProgressDialog? Just add a Progress Bar to your layout and work with it the same way you're doing it with the dialog. Every dialog blackens the screen by default, it just comes from the logic of dialogs.
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ProgressBar1.html Here is the example of progressbar usage.
This question already has an answer here:
Android Progress Bar is not dismissed
(1 answer)
Closed 8 years ago.
I have a dashboard section in my android application where once a user clicks on a button, a preogressDialog is show ("Please Wait") and the next activity loads up. But when i click the android device bacj button, the progress bar is still showing up. I used dismiss() but to no use. Any help is appreciated.
progressDialog.setMessage("Please wait...");
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.show();
browseCategories();
protected void browseCategories() {
Log.i(MY_DEBUG_TAG, "Bow!");
Intent c = new Intent(this, CategoryListActivity.class);
c.putExtra("user", u);
startActivity(c);
}
Using a progress dialog in an activity immediately before starting another one doesn't make sense.
Activities are, for the most part, meant to be UI-oriented and when one starts another then the new one is 'layered' over the top of the first.
If the CategoryListActivity is going to take some time before it is ready for use (loading data for example), then it should show a progress dialog and not the activity that starts it. Using an AsyncTask for loading data or any operation which will take an extended time is the best way to proceed.
I suggest you read about Application Fundamentals and the Activity Lifecycle
in layout XMl file :
<ProgressBar
android:layout_marginTop="60dip"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/prgressbar"
android:visibility="invisible"
/>
in Onclick event of button do this:
ProgressBar prgressbar;
prgressbar=(ProgressBar)findViewById(R.id.prgressbar);
prgressbar.setVisibility(LinearLayout.VISIBLE); // this of visible the progress bar
prgressbar.setVisibility(LinearLayout.INVISIBLE); // this is for invisible