dismiss Progress Dialog in another Activity ... Android
Asked Answered
A

2

4

I have Tow Activities:

  1. FirstPageActivity
  2. SecondPageActivity

The App call the SecondPageActivity by the FirstPageActivity... and the App send HttpRequest In the SecondPageActivity.

So I want to show Progress Dialog in the FirstPageActivity and After the SecondPageActivity Finish downloading the data, it Dismiss the Progress and then Appear.Is that Possible ?

Abroach answered 4/5, 2014 at 15:44 Comment(2)
why not showing the progress dialog in 2nd activity?!!Confabulation
Actually The Customer doesn't want to show the progress in the second Activity Because it will be empty for a while, and that not so good :(Abroach
A
4

I want to show Progress Dialog in the FirstPageActivity and After the SecondPageActivity Finish downloading the data, it Dismiss the Progress and then Appear.Is that Possible ?

No.

You can't handle one Activity's UI functionality or any functionality from another `Activity.

If you start a ProggressDailog in FirstPageActivity then you must be dismiss it in onPause() before proceeding to other Activity as you said SecondPageActivity.

You can start a new ProggressDailog in SecondPageActivity from onCreate() or onResume() method.

Update: From the document of ProggressDailog you can see, to initialize a ProggressDialog its need to pass the current Activity context.

ProgressDialog(Context context)
ProgressDialog(Context context, int theme)
Aggiornamento answered 4/5, 2014 at 15:47 Comment(5)
So if I want to do that, I should Download the data in the FirstPageActivity and then send it to SecondPageActivity...Abroach
Yeah, that will be a good way. Can I know what is the purpose of SecondPageActivity? If say the purpose then I can help you in more specific way.Aggiornamento
yes, it will show the downloaded data from the http request, Actually I want to show the progress in the firstActivity because I don't want to show the progress bar on an empty activity until it finish download the dataAbroach
are you downloading data in FirstPageActivity or in SecondPageActivity?Aggiornamento
I will explain my problem again : I want the behind view of the progress dialog to be the firstPageActivity, and when the second Activity ready to appear "that mean that has been downloaded the data" so I will dismiss the progress and show the second Activity. now I think this impossible if I download the data in the second Activity , and the only solution is to downloaded in the first Activity !!!! that's right ???Abroach
C
1
and the App send HttpRequest In the SecondPageActivity.

As you say SecondPageActivity send HttpRequest , then best way is to show the ProgressDialog in SecondPageActivity.

In onCreate of SecondPageActivity show the ProgressDialog and dismiss it when HttpRequest complete

Cubism answered 4/5, 2014 at 15:51 Comment(8)
Yes I agree with you,but Actually the Customer want to show the progress in the firstPageActivity, Instead of showing progress in the SecondActivity, because SecondActivity will be empty for a while :(Abroach
You can still show the ProgressDialog in FirstActivity and dismiss it after SecondPageActivity is startedCubism
yes but then the second activity will be empty for a while, until it download the data ,,, yes ?Abroach
No. As I said show the dialog in onCreate of secondActivityCubism
ok, but then the first activity will be disappeared and the background of the progress will be an empty activity because the data didn't download !!!!Abroach
You said the secondActivity is the one downloading the data, so I believe it will start download only after it is invoked by FirstActivity. When you start the Activity, immediately it will be on top of the stackCubism
I will explain my problem again : I want the behind view of the progress dialog to be the firstPageActivity, and when the second Activity ready to appear "that mean that has been downloaded the data" so I will dismiss the progress and show the second Activity. now I think this is impossible if I download the data in the second Activity , and the only solution is to downloaded in the first Activity !!!! that's right ???Abroach
Yes, an Activity should be in Foreground to start a download request. It is better to do it in FirstActivity and then start the SecondActivity.Cubism

© 2022 - 2024 — McMap. All rights reserved.