如何在活动之间传递值 [英] How to pass values between activity

查看:66
本文介绍了如何在活动之间传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了3个活动:firstActivitysecondActivitythirdActivity.

I have created 3 activities: firstActivity, secondActivity, and thirdActivity.

  1. firstActivity是主要活动.
  2. secondActivity仅在收到短信后才起作用,然后将其发送到thirdActivity.
  3. thirdActivity将字符串值转换为双精度值,然后将双精度值发送到firstActivity.
  1. firstActivity is the main activity.
  2. secondActivity will work only if it receives an SMS, and it then sends the message to thirdActivity.
  3. thirdActivity converts the string values to double values, and then sends the double values to firstActivity.

我可以将值从secondActivity发送到thirdActivity,但是我不知道如何将值从thirdActivity传递到firstActivity.请给我建议我该怎么做.

I can send values from secondActivity to thirdActivity, but I don't know how to pass values ​​from thirdActivity to firstActivity. Please advise me on how I should do this.

推荐答案

每当您有一个需要结果的活动时,例如在这种情况下,您就拥有了ThirdActivity,那么您始终可以使用方法

Whenever you have an activity called for a result, like in this case you have thirdActivity you can always use the method startActivityForResult instead of just startActivity. Once thirdActivity has finished its processing and it wants to return the result value, it should call setResult and that's it.

此方法的问题在于,您在中间有点"secondActivity".真的有必要吗?

The problem with this approach here is that you kind of have secondActivity in the middle. Is it really necessary?

这篇关于如何在活动之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆