onNewIntent is not called

后端 未结 7 2121
暗喜
暗喜 2020-12-01 05:32

I have very strange situation.
Having one app, I decided to create another one from the code of first one.
I copied .xml files, copied .java files so that everythin

7条回答
  •  庸人自扰
    2020-12-01 05:37

    I was using onNewIntent for search implementation in Android. I came across the problem that onNewIntent wasn't being called when I used the Go button on the keyboard in the emulator. I solved the issue by placing my code for handling the intent in the onCreate method also. This needs to be done to make sure that the intent action is handled when a fresh instance of the activity is started.

    This posed a problem as onCreate is called whenever the activity is restored from a previous state too. So, the intent handling method gets called even when an orientation change occurs.

    Solution : Use if (savedInstanceState==null) to determine if activity is being restored from a previous state, or is it a fresh search.

提交回复
热议问题