The action or category (or data or mime type) in the launching intent
doesn't matter at all for what will happen with the result.

When you are in your second activity, you can try "adb shell dumpsys
activity" to see the current activity stacks (they are the first thing
printed; there is a lot more).  Your sub-activity should be on top, and it
will include where its result will go to, if there is a target.

The code you posted look okay to me, but you didn't include your code that
actually starts the activity and that is the most likely culprit -- if you
use startActivityForResult() you should be guaranteed to get -some- result
back, no matter what.

On Sat, Feb 13, 2010 at 4:36 AM, WirelSys <[email protected]> wrote:

> I have problem too while attempting to return a result from my child
> activity. From the logs it appears that my sub-activity does execute
> setResult() and finish(). However, it still fails to execute
> onActivityResult in the main (calling) activity.
>
> ----------------------------------------------------------
>
> Here is the Manifest code for the child activity:
>
>        <!-- This activity displays the 'About' screen to the user. --
> >
>        <activity
>            android:launchMode="standard"
>            android:name=".TFTAbout"
>            android:label="@string/about">
>        </activity>
>
>
> The child activity's code:
>
>    @Override
>    public void onCreate( Bundle savedInstanceState )
>    {
>         Log.d( LOG_TAG, "onCreate: START" );
>
>        super.onCreate( savedInstanceState );
>
>        /* Set what to do when the user presses a key but the key
> press is
>         * not handled by the application. */
>        setDefaultKeyMode( DEFAULT_KEYS_DISABLE );
>
>        /* Connect the appropriate resource to this activity. */
>        setContentView( R.layout.about );
>
>        /* Define the click listener for the Close button. */
>        Button b = (Button) findViewById( R.id.bt_close );
>        b.setOnClickListener
>        (
>            new View.OnClickListener()
>                {
>                                /** Implement the OnClickListener callback
> to handle the press of
> a button. */
>                             public void onClick( View v )
>                            {
>                                 Log.d( LOG_TAG, "bt_close.onClick: START. "
> );
>                                setResult( 2, (new
> Intent()).setAction("About activity has
> finished!") );
>                                Log.d( LOG_TAG, "onClick: 'Close' button
> pressed; returning
> to calling activity." );
>                                finish();
>                                Log.d( LOG_TAG, "bt_close.onClick: END. " );
>                            }
>                }
>            );
>    }
>
>
> And the parent activity's code:
>
>    @Override
>        protected void onActivityResult( int request_code, int result_code,
> Intent i )
>    {
>        Log.d( LOG_TAG, "onActivityResult: START." );
>
>        super.onActivityResult( request_code, result_code, i );
>
>        /* Use the request code to select between multiple child
> activities we
>         * may have started. Here there is only one thing we launch.
> */
>        if ( request_code == Activity.RESULT_FIRST_USER )
>        {
>            Log.d( LOG_TAG, "onActivityResult: 'About' activity has
> returned." );
>        }
>    }
>
>
> Logcat:
>
> 02-13 13:55:42.057: DEBUG/TFT(6716): onOptionsItemSelected: 'About'
> item selected.
> 02-13 13:55:42.070: INFO/ActivityManager(564): Starting activity:
> Intent { comp={com.wirel.tft/com.wirel.tft.TFTAbout} }
> 02-13 13:55:42.146: DEBUG/TFTAbout(6716): onCreate: START
> 02-13 13:55:42.178: DEBUG/TFTAbout(6716): onCreate: END
> 02-13 13:55:42.326: INFO/ActivityManager(564): Displayed activity
> com.wirel.tft/.TFTAbout: 254 ms
> 02-13 13:55:43.089: DEBUG/TFTAbout(6716): bt_close.onClick: START.
> 02-13 13:55:43.097: DEBUG/TFTAbout(6716): onClick: 'Close' button
> pressed; returning to calling activity.
> 02-13 13:55:43.106: DEBUG/TFTAbout(6716): bt_close.onClick: END.
>
> ----------
>
>
> The sub-activity has it's lauchMode set to 'standard'. I confirmed
> that I am passing a valid request code ( which is > 0 ).
>
> Also I ensured that the sub-activity's action is neither ACTION_MAIN
> or ACTION_VIEW as is stated in the documentation for
> startActivityForResult.
>
> Can someone please help?
>
> Thanks.
>
> --
> 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%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
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, and so won't reply to such e-mails.  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