I am using two Activities, Old Activity and New Activity. I want to pass a value from New Activity to Old Activi开发者_运维技巧ty. How can I accomplish this?
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.
精彩评论