开发者

Passing a string from one activity to previous activity

开发者 https://www.devze.com 2023-02-09 14:34 出处:网络
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 thi

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 he开发者_如何学Clp me as soon as possible.

Thanks in advance..


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.

0

精彩评论

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