What could cause an Android activity to relaunch itself infinitely when returning from camera?

后端 未结 1 1380
我在风中等你
我在风中等你 2021-02-08 09:52

I have a weird bug in my application that causes an activity to relaunch itself in an infinite loop when I\'m returning from a camera application, after taking a picture.

<
1条回答
  •  迷失自我
    2021-02-08 10:06

    After much investigation, it appears the call to relaunch is coming from onConfigurationChanged. I still haven't figured out why, but at least I know what to avoid.

    It explains why some cameras triggered this bug and others not: some cameras used the same configuration as my application, others not.

    EDIT: I've discovered after other investigations that I had a bug in my extended Application class. In the onConfigurationChanged method, I was changing the configuration by forcing a certain locale. This was triggering a new onConfigurationChanged() call, which caused an infinite loop and the subsequent screen create/destroy sequence. I have no idea why I've put that code in the onConfigurationChanged() method, but I guess you have to suffer in order to learn :)

    0 讨论(0)
提交回复
热议问题