why does the ProgressBar in my DialogFragment stop spinning?

Go To StackoverFlow.com

0

I have the following structure:

in UIActivity1:

MyMyProgressDialogFragment progressDialog = MyMyProgressDialogFragment.newInstance();
progressDialog.show(getFragmentManager(),"dialog");
getFragmentManager().executePendingTransactions();
..do some heavy work and send messages to progressDialog

The DialogFragment gets created and the ProgressBar in this fragment starts spinning.

But when I now start the heavy work in the activity which created the dialog fragment the progress bar within the fragment stops.

When reading through the fragment doc I understand that a fragment has its own activity - same as the Ui Activity1. And afaik each activity runs in a separate thread.

So why does the progressbar in the dialog fragment stop when the UIActivity1 starts with its heavy work?

Shouldn't they be independant?

ps when I run the heavy work outside the UIActivity in a different task again, the progress bar keeps spinning without problems.

Where is my mistake in understanding here?

Thanks!

2012-04-04 22:33
by user387184


0

Its not clear from the information you have shared, however looks like you are doing all your heavy execution in your UI Thread. That is the activity's main thread. Whether the activity you spin off with your fragment is meant to do just this work is irrelevant, the UI thread has to be used only to update the UI elements and generally avoid tasks that take longer than 100 - 200 ms. This is as per android Non-Responsive Application documentation. This is probably the problem, any long standing or long executing tasks have to be done in a background thread.

Take a look at this example of using the progressbar in Android.

2012-04-04 22:41
by Ali
Oh of course you are right. I was under the wring assumption that as long as the DialogFragment is in the foreground I could "abuse" the UIActivity to do some heavy work since it does not need to do any screen updating. Well, as it looks, even when the UIActivity is not in the foreground and not really doing any UI work all other visible activities (like the fragment) also do not update. Thanks for point this out - user387184 2012-04-05 05:55
Ads