user3516596
user3516596

Reputation: 349

dismiss Progress Dialog in another Activity ... Android

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 ?

Upvotes: 4

Views: 2691

Answers (2)

Hamid Shatu
Hamid Shatu

Reputation: 9700

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)

Upvotes: 4

Libin
Libin

Reputation: 17085

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

Upvotes: 1

Related Questions