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 passed to the Activity.
How can I clear that Intent to prevent Activity from using it again?
I've tried setIntent(null)
, but with no result.
I had similar problem. This helped me. Maybe you have to also use onSaveInstanceState(Bundle outState) and add extra data to the bundle so inState is not null, not sure.
Do not use
setIntent(null)
. It seems that while it may work sometimes, under some conditions the original intent may come back.Instead, callsetIntent()
with a simple intent that doesn't have an action, data or extras, such asnew 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 yoursavedInstanceState
is still null.If your intent is sent to your activity with an action (with setAction), just do the following when you receive the intent, to avoid multiple handling of this intent when screen rotates :