onActivityResult method not being called Android

前端 未结 9 1724
误落风尘
误落风尘 2020-12-08 07:58

I am trying to send data from child activity to parent. But somehow, onActivityResult(..) is not getting called. here is code

Parent activity

selecte         


        
9条回答
  •  借酒劲吻你
    2020-12-08 08:18

    For anyone stuck with same problem, a symptom not to receive onActivityResult, following cases can cause this issue.

    • check you are using startActivityForResult() correctly, do not use startActivity().
    • if you do something in overriden onBackPressed method, super.onBackPressed(); has to be positioned at the last of the method, not at the first line. (my case to spend 5 hours)
    • remove android:launchMode="singleInstance" in manifest or equivalent argument to create a intent.
    • remove noHistory="true" in manifest of the callee activity.
    • check setResult() is missed.
    • finish() is called to close the activity. use finishActivity() to close callee activity.
    • use requestCode more than zero. negative value does not work.

提交回复
热议问题