问题
I have Tow Activities:
FirstPageActivitySecondPageActivity
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 ?
回答1:
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)
回答2:
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
来源:https://stackoverflow.com/questions/23458162/dismiss-progress-dialog-in-another-activity-android