接收从第二项活动的响应

2023-09-12 05:45:50 作者:素手披薄衣

我是初学者在Android中,我只是想知道如何从第二个活动的响应,而我来自第一项活动。

I am beginner in android, I just want to know how to get the response from the second activity to which I came from first activity.

任何机构可以告诉我这样做的方法是什么?难道是之前在调用完成()?

Can any body tell me the way to do this? Is it before while calling finish() ?

我会很感激,如果任何人能告诉我code段。

I would be thankful if any one can show me the code snippet.

推荐答案

您必须调用使用 startActivityForResult 方法的第二个活动。在你的第二个活动,当它完成,你可以执行的setResult 方法,其中基本上你把结果信息。然后,在你的第一个活动,你重写 onActivityResult 方法。

You must call the second activity using the startActivityForResult method. In your second activity, when it is finished, you can execute the setResult method where basically you put the result information. Then, on your first activity, you override the onActivityResult method.

相关推荐