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.
The easiest way to do this would be to pass the session id to the signout activity in the Intent you're using to start the activity: Intent intent = new Intent(getBaseContext(), SignoutActivity. class); intent. putExtra("EXTRA_SESSION_ID", sessionId); startActivity(intent);
Use finishAffinity() to clear all backstack with existing one. Suppose, Activities A, B and C are in stack, and finishAffinity(); is called in Activity C, - Activity B will be finished / removing from stack. - Activity A will be finished / removing from stack. - Activity C will finished / removing from stack.
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.
Intent activityIntent = null; // Subsequent times it's null @Override protected void onCreate(Bundle inState) { super.onCreate(inState); . . if (inState!=null) { /*Recreating activity with a saved state*/ } else { /*Creating activity*/ activityIntent = getIntent(); // First time through intent is used /*Get your Extra Intent data here. You will be capturing data on 1st creation. */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With