I am new to android application I have a task is that i should pass data from activity A->Activity B and should pass data between Activity B-----------> Activity C Same way I should get data from Activity C-------> Activity A please tell the scenario or send an example for me
Asked
Active
Viewed 58 times
0
-
Your question does not show any effort on your part. Have you considered passing `bundle` objects via `Intent`? – Amulya Khare Nov 22 '13 at 11:23
-
Please read documentation for `startActivityForResult` – Simon Nov 22 '13 at 11:23
3 Answers
0
Try two options 1). Intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("KEY", "VALUE");
startActivity(intent);
2). Shared Preference
if the data is shared between all activities.

Vaibs
- 1,128
- 3
- 16
- 36
0
Intent
is what you needed:
Intent mIntent = new Intent(ActivityA.this, ActivityB.class);
mIntent.putExtra("key", "value");
startActivity(mIntent);
The above code starts ActivityB
and sends the data along with it, to ActivityB (from mIntent.putStringExtra("key", "value");
)
You can also see the different prototypes of this from here.
On the next activity, ActivityB
, you can get the data sent by code below (write it inside onCreate() in ActivityB
):
Intent mIntent = getIntent();
String data_recieved = mIntent.getStringExtra("key"); \\ here key is same as mentioned in previous activity from where you reached here.

Chintan Soni
- 24,761
- 25
- 106
- 174
-
But i want to pass data from Activity C to Activity A and also call Activity A – ANAND PRABHAKAR Nov 22 '13 at 12:08
0
You can pass data from A to B by using intent:
Intent intent = new Intent(this, Activity.class);
intent.putExtra("name", "value");
startActivity(intent);
You can return back value using onActivtyResult()
or by storing it in
shared preferences
If you are using onActivtyResult()
method you need to start activty for result using : startActivityForResult()
method
You can check this for sending data back send data back to activity