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.
-
http://stackoverflow.com/questions/12282288/pass-value-from-1st-activity-to-3rd-activity – Kuldeep Singh Jul 11 '15 at 05:00
-
http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android – Amitabha Biswas Jul 11 '15 at 05:22
4 Answers
Yes You are right . you can use intent.putExtra()
- You can do Pass data using
intent.putExtra()
from activity A to activity B . - Then sote that bundle in activity B
- Then When you launching Activty c pass that bundle to intent
- Catch that data in activity c

- 27,217
- 13
- 76
- 96
-
-
But again, the trouble is , Activity C is launched from a Broadcast receiver – OBX 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
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.

- 654
- 6
- 22
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.

- 1,894
- 3
- 17
- 35
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
.

- 4,521
- 4
- 33
- 57

- 1,899
- 1
- 20
- 35