我怎样才能使用完成发回的数据? [英] How can i send back data using finish?

查看:122
本文介绍了我怎样才能使用完成发回的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像我可以从一个活动使用此数据发送到另一个问题:

Like i can send data from one activity to another using this:

intent.putExtra("Name", Value);

我怎么能在我使用完成()来返回到previous活动发送数据。

how can i send data when i am using finish() to get back to the previous activity.

在从 Activity_A 我的应用我要去到 Activity_B 。在 Activity_B 我正在标记在地图上的位置,这使我的经度和纬度。然后,我想用这种lat和液化天然气在 Activity_A 。但我不想回去 Activity_A 使用意图,因为我不想重新创建 Activity_A 因为有些数据已经填写将会丢失。

In my app from Activity_A i am going to Activity_B. In Activity_B i am marking a location on map, which gives me latitude and longitude. Then i want to use this lat and lng in Activity_A. But i don't want to get back to Activity_A using an intent, because i don't want to recreate the Activity_A since some data already filled will be lost.

推荐答案

由于您使用的是 intent.putExtra(名,值); ,使用同样的事情一边整理活动也。

As you are using intent.putExtra("Name", Value);, use the same thing while finishing the activity also.

有关例如:

从activityA你打电话activityB这样的:

From activityA you call activityB like:

intent.putExtra("Name", Value);
now instead of startActivity() use `startActivityForResult()`

和来自activityB,一边整理活动,请致电:

And from activityB, while finishing the activity, call:

setResult(RESULT_OK);

现在在activityA,你的的onActivityResult 将被调用,这是这样的:

Now in activityA, your onActivityResult will be called, which is like:

@覆盖

   protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        // TODO Auto-generated method stub
}

所以inthis方式,您可以处理它。

So inthis way you can handle it.

这篇关于我怎样才能使用完成发回的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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