2

I want to pass an object from Activity B to Activity A.

Scenario: - Activity A calls Activity B - User selects item in Activity B - Activity B passes an object to Activity A

How do I accomplish this? And in which method do I read in the passed object in Activity A?

Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

2 Answers2

4

you can start your intent using startActivityForResult on Activity A ... And when finishing Activity B declare a bundle and put your serializable object to your bundle and add it to your intent. On Activity A's onActivityResult method you can get this intent back and retrieve your bundle...

Refer to this sample below.

http://micropilot.tistory.com/1577

DeRagan
  • 22,827
  • 6
  • 41
  • 50
  • I have an interesting problem. I have an Activity that calls a Search Manager which directs me to Activity B. I want to pass some data from B to A at this point. onActivityResult never gets called in Activity A. – Sheehan Alam Aug 30 '10 at 15:39
  • See the following question: http://stackoverflow.com/questions/3597919/how-to-handle-callback-from-search-manager – Sheehan Alam Aug 30 '10 at 15:40
1

Intents are used to send data between 2 activities....If its serializable data than send it using: Eg: Intent myIntent = new Intent(home.this,dvd.class); myIntent.putExtra(name, value);

Rohan K
  • 1,608
  • 4
  • 21
  • 32