This generally happens when the new activity is being launched into a
different task than the initial activity.  Make sure your first activity
does not have the launch mode singleInstance, the second doesn't have the
launch mode singleTask or singleInstance, you don't use the NEW_TASK intent
flag when launching the activity, etc.

On Wed, Jan 7, 2009 at 4:56 PM, Stoyan Damov <[email protected]> wrote:

>
> Hi again guys,
>
> I'm trying to launch a sub-activity from my "main" activity and
> although the sub-activity does launch (and it's view gets shown), the
> parent activity's onActivityResults always gets called back with a
> result of RESULT_CANCELED immediately after I call
> startActivityForResult (and then the sub-activity gets launched).
>
> Here's the main activity's relevant code:
>
> private void launchSubActivity()
> {
>    Intent intent = new Intent(this, SubActivityClassName.class);
>    startActivityForResult(intent, REQUEST_CODE); // REQUEST_CODE is >= 0
>
>    // Here, I would expect to *not exit* the function *before*
> onActivityResult is called (or an activity's lifecycle event triggers)
> }
>
> @Override
> protected void onActivityResult(int requestCode, int resultCode, Intent
> data)
> {
>        super.onActivityResult(requestCode, resultCode, data);
>        if (resultCode != Activity.RESULT_CANCELED)
>        {
>                // I never get here because the result is always
> RESULT_CANCELED
>                Toast.makeText(this, "Blah", Toast.LENGTH_SHORT).show();
>        }
> }
>
> Here's the sub-activity's relevant code (although it's really
> irrelevant in this case):
>
> private void handleThisOrThatClick()
> {
>    setResult(RESULT_CODE); // RESULT_CODE is > Activity.RESULT_CANCELED
>    finish();
> }
>
> Am I missing something obvious here?
> Thanks!
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
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