Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear Intent that started Activity?

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.

like image 847
pixel Avatar asked Jun 30 '10 10:06

pixel


People also ask

How do you pass an activity in intent?

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);

How do I delete my Backstack activity?

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.


1 Answers

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. */ } 
like image 52
dcg Avatar answered Oct 11 '22 02:10

dcg