setResult does not work when BACK button pressed

前端 未结 10 1940
南方客
南方客 2020-11-27 13:08

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

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

But

10条回答
  •  没有蜡笔的小新
    2020-11-27 13:53

    Don't rely on any logic executed in onPause of one activity when you return to the initial one. According to the docs:

    Implementations of this method (onPause) must be very quick because the next activity will not be resumed until this method returns

    See http://goo.gl/8S2Y for details.

    The safest way is to set result after each result altering operation is complete (as you mention in your answer)

提交回复
热议问题