How to clear Intent that started Activity?

后端 未结 9 1168
攒了一身酷
攒了一身酷 2021-02-03 21:07

At the beginning Activity is launched by an Intent and something is done with this Intent.

When I change orientation of my Activity, it\'s reloaded again and Intent is

9条回答
  •  孤独总比滥情好
    2021-02-03 21:48

    Do not use setIntent(null). It seems that while it may work sometimes, under some conditions the original intent may come back.

    Instead, call setIntent() with a simple intent that doesn't have an action, data or extras, such as new Intent(Context, Class).

    Indeed, the use of setIntent() was actually not a good API design decision in the first place. Instead, as dcg noted, be sure you only check your intent the first time, when your savedInstanceState is still null.

提交回复
热议问题