Hi guys,
I think there's a bug in either showDialog, dismissDialog or
showing/dismissing a ProgressDialog using these 2 methods, which might
or might not be related to the fact that I'm displaying the dialog
from another thread (marshalled correctly via runOnUiThread).
Here's what I do:
I have a UI thread with a SurfaceView, and another thread which is
doing something asynchronously and needs to show progress.
So, let's say I have these methods on my view, which are accessed by
the background thread:
// BEGIN CODE
private static final int PROGRESS_DIALOG_ID = 888;
private String mProgressMessage;
void showProgress(final String message)
{
mProgressMessage = message;
mActivity.runOnUiThread(new Runnable()
{
public final void run()
{
System.out.println("DIALOG " + PROGRESS_DIALOG_ID + ":
about to display: " + message);
mActivity.showDialog(PROGRESS_DIALOG_ID);
}
});
}
and
void hideProgress()
{
mActivity.runOnUiThread(new Runnable()
{
public final void run()
{
mActivity.dismissDialog(PROGRESS_DIALOG_ID);
System.out.println("DIALOG " + PROGRESS_DIALOG_ID + ":
dismissed");
}
});
}
Here's the implementation of onCreate/onPrepareDialog in my activity:
@Override
protected Dialog onCreateDialog(int id)
{
if (id == PROGRESS_DIALOG_ID)
{
System.out.println("DIALOG " + id + ": onCreateDialog called");
mProgressDialog = new ProgressDialog(this);
// setXxx, setYyy...
mProgressDialog.setMessage(mProgressMessage);
return mProgressDialog;
}
return super.onCreateDialog(id);
}
@Override
protected void onPrepareDialog(int id, Dialog dialog)
{
super.onPrepareDialog(id, dialog);
if (id == PROGRESS_DIALOG_ID)
{
((ProgressDialog)dialog).setMessage(mProgressMessage);
System.out.println("DIALOG " + id + ": prepared with message:
" + mProgressMessage);
}
}
// END CODE
So, in my background thread, I call showProgress("Some message"), do
some work, and then call hideProgress() - this works, and the output
is:
DIALOG 888: about to display: Some message
DIALOG 888: onCreateDialog called
DIALOG 888: prepared with message: Some message
DIALOG 888: dismissed
But most importantly is that the dialog is indeed displayed.
Then, I chose an item from my menu, which makes the background thread
do some more work, and again it calls:
showProgress("Blah"), does some work, and then hideProgress -
according to the log all is good:
DIALOG 888: about to display: Blah
// onCreateDialog is NOT called, which is what's expected, the dialog is cached
DIALOG 888: prepared with message: Blah
DIALOG 888: dismissed
*EXCEPT* that the dialog is *NOT DISPLAYED* at all.
Now, this *IS* a bug and I'm pretty sure it's not mine too. I *know*
that, because even if I create the dialog and then *remove* it, and
then try to show another dialog (newly created, and even with a
different id!) it won't work either.
Has anyone experienced that and does anyone knows if there's a
workaround for this no matter how pervert it might be.
Thanks,
Stoyan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---