1

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.

N J
  • 27,217
  • 13
  • 76
  • 96
OBX
  • 6,044
  • 7
  • 33
  • 77

4 Answers4

2

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
N J
  • 27,217
  • 13
  • 76
  • 96
  • Thanks for answering that in a minimal way . – OBX Jul 11 '15 at 05:23
  • But again, the trouble is , Activity C is launched from a Broadcast receiver – OBX Jul 11 '15 at 05:24
  • but you mentioned ` instead it is launched from Activity B` – N J Jul 11 '15 at 05:24
  • Yes, Its an alarm, From activity B a Broadcast receiver is called, and at a specific system time, Activity C is launched – OBX Jul 11 '15 at 05:28
  • so what you can do is `you can create serialize object write it to shared preference and access for there or put int into shared preference in and access that in activity c – N J Jul 11 '15 at 05:30
0

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.

0

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.

Parth Bhayani
  • 1,894
  • 3
  • 17
  • 35
0

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.

moffeltje
  • 4,521
  • 4
  • 33
  • 57
Ram Mandal
  • 1,899
  • 1
  • 20
  • 35