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.
My suggestion would be to toggle this with a boolean variable to check wheather your activity is first created or not.
Otherwise you can look at your onCreate method, afaik this is only executed, when the activity is first created.
intent.putExtra(YourKey,""); //reset the value to knknown setIntent(intent);
In my case I needed to set the data to null:
Old post, but some one could use this.
Dont waste time, if your app is resumed, the intent will be there again.
Use the starting intent on the "Activity Resume", and just add an extra value
And each time your app resumes, check if already has this value:
easy
If you set the intent action, you can clear it with
getIntent().setAction("");
For example in
onCreate(...)
:This will clear the action, otherwise it will be called every time you rotate the device.
Even after manually clearing the Intent and Intent extras after they have been parsed, it seems as though Activity.getIntent() will always return the original Intent that started the Activity.
To get around this, I recommend something like this :
This way, there is a mechanism to dump the original Intent while still retaining the ability to explicitly retain certain parts of the original Intent / Intent extras.
Note that I haven't tested all Activity launch modes.