Your "block A" abd "block B" are essentually two diffrent functions.
It means after executing block A you need to save its state in the
activity class member variables then popup the dialog which on close
will call another method in the activity class that you call "block
B". This block B must de-serialize the state saved by "block A" and
then execute it. All this is possible but terribly complicated. It
would be much simpler to have something like this

// activity method
void doProcessing() {

...
if(user_input_needed()){
ModalDialog modal_dlg = new ModalDialog();
boolean fDialogClosedOK = ModalDialog.doModal();
if(!fDialogClosedOK) // user has cancelled the dialog, hault
processing
return;

... continue processing using required input data saved in modal_dlg
instance

}

On Jan 18, 12:26 pm, Frank Weiss <[email protected]> wrote:
> I think I understand the issue, but I'm puzzled why you can't simply
> refactor your code to the Android API. Here's an example.
>
> Activity.myMethod() {
> { block A }
> ret = showModalDialog(); // they way you expect it to work
> if (ret == 1) {
> { block B }
>
> }
>
> This can be refactored to:
>
> Activity.onCreateDialog() {...
> AlertDialog.Builder builder = new AlertDialog.Builder(this);
> builder.setMessage("Do you want to continue?")
>        .setCancelable(false)
>        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
>            public void onClick(DialogInterface dialog, int id) {
>                * { block B }*
>                 MyActivity.this.finish();
>            }
>        })
>        .setNegativeButton("No", new DialogInterface.OnClickListener() {
>            public void onClick(DialogInterface dialog, int id) {
>                 dialog.cancel();
>            }
>        });
> AlertDialog alert = builder.create();
> ...}
>
> Activity.myMethod() {
> { block A }
> showDialog(CONTINUE_WITH_B_DIALOG);
>
> }
>
> If this code is correct, doesn't it accomplish the same behavior from the
> user's point of view?
>
> On Mon, Jan 18, 2010 at 8:34 AM, swapnil kamble <[email protected]>wrote:
>
>
>
> > I have solved this problem by a synch point between two thread i.e. using
> > CountDownLatch
>
> >   On Mon, Jan 18, 2010 at 6:32 PM, skink <[email protected]> wrote:
>
> >> On Jan 18, 1:52 pm, ls02 <[email protected]> wrote:
> >> > Yes, I read Android docs about dialogs. However, this still does not
> >> > answer my trivial questions. I also do not want to block UI thread.
> >> > Blocking UI thread means you block message pump and UI becomes
> >> > unresponsive. What I want is to call the function from UI thread that
> >> > would popup the dialog and this function will not return until the
> >> > dialog is closed. It is obvious that this modal dialog internally must
> >> > implement message pump and break this message loop when user closes
> >> > the dialog. Something similar to DialogBox or MessageBox Windows APIs.
> >> > I understand that I can implement OnClickListener, but this will
> >> > effectively call another function in the activity class that pops up
> >> > this dialog. I cannot this way to return to the same execution point
> >> > in the function that popped up the dialog.
>
> >> > If Android does not have truly modal dialog I wonder what the
> >> > suggested approach to the following standard situation. Say you have
> >> > function that at certain point needs to prompt user for some input via
> >> > a modal dialog and then must use the input from the dialog to continue
> >> > its execution.
>
> >> see:
>
> >>http://groups.google.com/group/android-developers/browse_thread/threa...
>
> >> pskink
>
> >> --
> >> 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]<android-developers%2bunsubs­[email protected]>
> >> For more options, visit this group at
> >>http://groups.google.com/group/android-developers?hl=en
>
> > --
> > ...Swapnil
>
> > || Hare Krishna Hare Krishna Krishna Krishna Hare Hare ||
> > || Hare Rama    Hare Rama   Rama   Rama    Hare Hare ||
>
> > --
> > 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]<android-developers%2bunsubs­[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en- Hide quoted text -
>
> - Show quoted text -
-- 
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

Reply via email to