OBX
OBX

Reputation: 6114

Passing data between Activities Android | java

Consider three Activities, A,B,C . I want to pass data from Activity A to Activity C, however Activity C is not launched from Activity A , instead it is launched from Activity B, So what I am looking for is a solution if I can send an Integer value to Activity C from Activity A , and Activity C receives that value whenever it gets executed, can I use intent.putExtra() for this purpose? Any help will be appreciated.

Upvotes: 1

Views: 94

Answers (4)

Ram Mandal
Ram Mandal

Reputation: 1959

if intent.putExtra() does not work for you then you can try saving data in application level.
You can save data from A to certain variable which is in Application level. Or you can just use sharedPreferences or sqlite.

Upvotes: 0

Parth Bhayani
Parth Bhayani

Reputation: 1924

You can keep passing the bundle to activity B and get that data through intent and same thing you can pass that same bundle in activity B on click of a button or the selected view and get the same intent in Activity C, so finally your query has to be fulfill.

Upvotes: 0

Programming Pirate
Programming Pirate

Reputation: 654

I don't have the reputation to comment so giving it as answer. You answered in your question, intent.putExtra is the way to go. But pass the value from A to B and B to C, if you find it annoying make use of shared preferences and put value from activity A and when needed in activity C get the value and use it.

Upvotes: 0

N J
N J

Reputation: 27505

Yes You are right . you can use intent.putExtra()

  1. You can do Pass data using intent.putExtra() from activity A to activity B .
  2. Then sote that bundle in activity B
  3. Then When you launching Activty c pass that bundle to intent
  4. Catch that data in activity c

Upvotes: 2

Related Questions