[android-developers] How to make the calling activity wait for the sub-activity to return and then proceed

2010-04-15 Thread Krish
Experts:

My MainActivity launches a SubActivity by calling:
startActivityForResult(intent, REQ_CODE);

The SubActivity shows a dialog that has two buttons: Yes, No

For the dialog, I've the following code:

...
...
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK */
setResult(DialogInterface.BUTTON_POSITIVE);
finish();
}
...
...

Similar code for handling NEGETIVE result as well.

In my MainActivity, I've onActivityResult(...) method defined to
handle appropriate result code (which is a very standard code).

My manifest has the following entry for the SubActivity:

activity android:name=.activity.ShowDialog
android:theme=@android:style/Theme.NoTitleBar
intent-filter
action android:name=android.intent.action.MAIN /
category
android:name=android.intent.category.DEFAULT /
/intent-filter
/activity

I was expecting that when the user hits either Yes or No button, the
calling activity's onActivityResult(...) methid would be fired with
all the intended parameters. But, I found that the calling activity
(MainActivity) is not waiting for  the SubActivity to finish (hiting
Yes/No button). I thought, untill an appropriate button is pressed it
has no result to be given back to the calling activity and that makes
sense for a method like startActivityForResult(...).

My intention is to launch an another activity based on the result
received from the SubActivity, but it is always landing up in a blank
page (reason is obvious). This is such a common scenario, I'm sure
that I have made a mistake somewhere. Need your help.

Kind Regards,
Krish

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] How to make the calling activity wait for the sub-activity to return and then proceed

2010-04-15 Thread ~ TreKing
On Thu, Apr 15, 2010 at 1:55 PM, Krish biswas.krish...@googlemail.comwrote:

 This is such a common scenario, I'm sure that I have made a mistake
 somewhere.


You're not handling onActivityResult()
http://developer.android.com/intl/de/reference/android/app/Activity.html#onActivityResult(int,
int, android.content.Intent)

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en