onActivityResult doesn't work?

前端 未结 6 967
走了就别回头了
走了就别回头了 2020-12-18 19:54

I am facing with a problem related startActivityForResult()

To start SecondActivity from FirstActivity :

Intent intent = new Intent();
intent.setClas         


        
6条回答
  •  臣服心动
    2020-12-18 20:51

    I was stuck here for a while. Adding my problem here to make sure that you don't scratch your head as well.

    The second parameter of this function has to be 0 or higher.

    startActivityForResult(intent, 0); // <- this is OK
    

    I was setting the second parameter to RESULT_OK, which is -1, and my onActivityResult callback was never getting called. So if you get stuck like me, you can also check if your second parameter is correct.

    startActivityForResult(intent, RESULT_OK); // <- this is wrong
    

    The above line will fail to call onActivityResult.

提交回复
热议问题