Reputation: 1867
I am using two Activities, Old Activity and New Activity. I want to pass a value from New Activity to Old Activity. How can I accomplish this?
Upvotes: 1
Views: 1227
Reputation: 126445
an example::
Bundle bundle = new Bundle();
bundle.putInt("newPicPosition", position);
Intent intent = new Intent(NewActivity.this, OldActivity.class);
intent.putExtras(bundle);
setResult(Activity.RESULT_OK, intent);
finish();
use setResult()
public final void setResult (int resultCode, Intent data) Since: API Level 1 Call this to set the result that your activity will return to its caller.
Parameters::
resultCode The result code to propagate back to the originating activity, often RESULT_CANCELED or RESULT_OK
data The data to propagate back to the originating activity.
Upvotes: 3