dismiss Progress Dialog in another Activity … Android

时光总嘲笑我的痴心妄想 提交于 2019-12-12 15:52:07

问题


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 ?


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!