sailaja
sailaja

Reputation: 61

Passing a string from one activity to previous activity

I am trying to pass a string from current activity to previous activity. I tried with intent, but it got failed. how can i pass it? Can anyone help me to find a solution for this?....i struck with this from 4 days... please help me as soon as possible.

Thanks in advance..

Upvotes: 1

Views: 1449

Answers (1)

Axarydax
Axarydax

Reputation: 16603

before your new activity (B) is finishing, use setResult()

Intent data = new Intent();
data.putExtra("RESULT", "my string to pass to previous activity");
setResult(RESULT_OK, data);

and in the previous activity (A) you must use startActivityForResult() for starting the activity B

then in activity A override onActivityResult() to retrieve the result.

Upvotes: 6

Related Questions