在多个活动中处理进度对话框

时间:2014-10-23 10:51:45

标签: android progressdialog

在我的项目中,我需要在一个活动中启动progress dialog并需要在另一个活动中停止它。这是我的代码。

progress.setMessage("Searching... ");
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setIndeterminate(true);
progress.show();
Intent intent = new Intent(mContext,BirdsAlgorithm.class );
intent.putExtras(bundle);
startActivity(intent);

我需要在BirdsAlgorithm课程中停止此进度条。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

进度对话框在UI线程上运行。所以你不应该做这样的事情。 相反,您可以关闭进度,并在新活动中启动新的实例。

答案 1 :(得分:0)

您有两种选择:

1. make progress static and public and then in next activity access it through the class name and then stop it.

2. override on destroy and on stop method for activity and then on stop and on destroy stop your progress thats it