的setResult不工作的时候BACK按钮pressed [英] setResult does not work when BACK button pressed

查看:151
本文介绍了的setResult不工作的时候BACK按钮pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想的setResult后返回按钮是pressed。我的onDestroy叫

I am trying to setResult after the BACK button was pressed. I call in onDestroy

Intent data = new Intent();
setResult(RESULT_OK, data) 

但是,当涉及到

But when it comes to

onActivityResult(int requestCode, int resultCode, Intent data) 

结果code为0(RESULT_CANCELED)和数据是'空'。

the resultCode is 0 (RESULT_CANCELED) and data is 'null'.

那么,如何可以通过从活性BACK按钮终止的结果?

So, how can I pass result from activity terminated by BACK button?

推荐答案

我重构我的code。最初我prepared一些数据,并将其设置为活动导致的onDestroy(这不工作)。现在,我要返回的数据每次更新时设定的活动数据,并没有任何在的onDestroy。

I refactored my code. Initially I prepared some data and set it as activity result in onDestroy (this did not work). Now I set activity data each time the data to be returned is updated, and have nothing in onDestroy.

这篇关于的setResult不工作的时候BACK按钮pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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