Android onActivityResult NEVER called

前端 未结 7 697
执笔经年
执笔经年 2020-12-04 03:03

my onActivityResult method is never called. am using android 2.2

I am using a Tabhost, where TabHosts contain TabGroups which contain individual Activities.

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 03:23

    Judging from the many questions like this one, there are many reasons why a called activity may not trigger the caller's onActivityResult() method.

    One reason I found, was when I called startActivityForResult(intent, requestCode), with a requestCode value of less than 0. My application did not need a requestCode and the Android documentation said using < 0 would not send a requestCode.

    But the Android docs did not mention the consequence of a requestCode < 0. The consequence is that it prevents the caller's onActivityResult() method from ever being invoked! Ouch!

    Therefore, even if your app does not need a requestCode, you many still want to use one with a value >= 0.

    That's what I learned today:-)

提交回复
热议问题