onActivityResult() has Intent data as null after an Activity has finished

后端 未结 2 1694
旧时难觅i
旧时难觅i 2021-01-04 07:56

Hi there I am calling an startActivityForResult() and trying to process the result in the onAcvityResult() method. However, the Intent data is null and result is RESULT_CANC

2条回答
  •  执笔经年
    2021-01-04 08:40

    I looked at the proposed solution and the original question example. In my case , the same error above was reusing the same requestCode value.

    Pay attention to your requestCode on using startActivityForResult, each Activity call should have a different requestCode.

    If you reuse or don’t pay attention to your requestCode to be unique for each Activity call you will get the following error message:

    “onActivityResult() has Intent data as null after an Activity has finished” or ”Failure delivering result ResultInfo”.

    Use variable definition for each startActivityForResult,to ensure clarity. ex.

    public static final int INITIATIVE_REQUEST = 11

          Use a unique number for each of startActivityForResult.  
    

    Again repeating the same requestCode on multiple Activities will result on the above message.

提交回复
热议问题