如何通过活动之​​间的值 [英] how to pass values ​​between activity

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

问题描述

我已经创建了3项活动: firstActivity secondActivity thirdActivity

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你可以随时使用的方法<一href="http://developer.android.com/reference/android/app/Activity.html#startActivityForResult%28android.content.Intent,%20int%29"相对=nofollow> startActivityForResult ,而不是仅仅startActivity。一旦thirdActivity已经完成它的处理,并要返回结果的价值,它应该调用的setResult,仅此而已。

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天全站免登陆