0

I have Activity2 which is a TabActivity having child activities Activity3 and Activity4.Acticity2 is called from Activity1.I want results from child activity(Activity3 or Activity4) in Activity2.Any help on this...?

dheeps
  • 163
  • 1
  • 4
  • 13

1 Answers1

2
  • Use startActivityForResult instead of startActivity to start Activity3 and Activity4.
  • Use setResult in your child activity to return data to the predecessor activity
  • Use onActivityResult in your parent activity to receive the result from the child activity

Edit: Added bundle information. Keeping original answer as it will likely be useful for others.

Since you aren't actually starting the activity with startActivity, you will need to store your data from the child activities, try this:

In TabActivity:

// putExtra is overloaded so you can add almost any kind of data.
// First parameter is the key, second is the value
getIntent().putExtra ( "Result", "OK" );

In parent activity:

// tabAct is the TabActivity object for your tab
// Here, just specify the key that you used in putExtra in your TabActivity
String actResult = tabAct.getStringExtra ( "Result" );
if ( actResult.equals ( "OK" ) {
    // Do your actions for success
}
else {
    // Do your actions for failure
}
RivieraKid
  • 5,923
  • 4
  • 38
  • 47
  • My problem is similar to this: http://www.anddev.org/other-coding-problems-f5/tabactivity-and-startactivityforresult-t7723.html#p26060 – dheeps Feb 01 '11 at 03:35
  • @RivieraKid Sir Can you please tell me How can I get the Result in my Activity You have told it in Parent Activity – Nitin Apr 11 '12 at 08:41
  • @Nitin you should start a new question for this. – RivieraKid Apr 11 '12 at 09:10
  • @RivieraKid Sir I have asked Question http://stackoverflow.com/questions/10103518/how-to-startactivity-for-result-from-activity-under-group-activity-under-tabs – Nitin Apr 11 '12 at 09:48