0

I have 6 activities in my app which are Activity1, Activity2, TabActivity, childTab1, childtab2, ExtraActivity.

App flow:

Activity1 => Activity2 => TabActivity =>ChildTab1 or ChildTab2 => ExtraActivity

Now i want to pass some data from ExtraActivity to Activity1. I am using StartActivityForResult for starting all activities.

ExtraActivity is able to send data to ChildTab1 or ChildTab2 but i unable to send that data back to TabActivity and further back to Activity2 and finally to Activity1.

Please help!!

Update: While searching, i got my solution via this post:

How to return a result (startActivityForResult) from a TabHost Activity?

Community
  • 1
  • 1
mudit
  • 25,306
  • 32
  • 90
  • 132
  • i am using intents only.. it was so obvious that's why i didn't mention that. The problem is that you cant define startactivityForResult when you add a tab in tabactivity.. may be thats why the intent set in setResult is getting lost. – mudit Oct 19 '11 at 11:05
  • use start activity and use putString() . – RajaReddy PolamReddy Oct 19 '11 at 11:09

2 Answers2

0

I think you can delegate the onActivityResult method-result from ChildTabX to TabActivity with ((TabActivity)getParent()).onActivityResult(). There you just call setResult and finish() again to send the result to Activity2. Same for Activity2

Rafael T
  • 15,401
  • 15
  • 83
  • 144
0

You could use the application context to pass data between activites.

Way to use app context.

Extend the application class and add the attributes as you require. So in your activity you can access the application context and get the data. As the application context is a singleton it will be the same instance in every activity.

MyApplication appContext = (MyApplication) getApplicationContext();
appContext.myString = "YOUR DATA;

In any other activity you can access that bitmap the same way.

MyApplication appContext = (MyApplication) getApplicationContext();

Now the string is in the appContext object.

You also need to add

android:name=".MyApplication"

to application tag in the manifest file.

blessanm86
  • 31,439
  • 14
  • 68
  • 79