开发者

How can I pass a value from a new Activity to an old Activity?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜