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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en