Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLAG_ACTIVITY_NEW_TASK clarification needed

Tags:

People also ask

What is the use of Flag_activity_new_task?

Show activity on this post. When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in.

What is Flag_activity_new_task in Android?

The flags you can use to modify the default behavior are: FLAG_ACTIVITY_NEW_TASK. Start the activity in a new task. If a task is already running for the activity you are now starting, that task is brought to the foreground with its last state restored and the activity receives the new intent in onNewIntent() .

What is Flag_activity_single_top?

FLAG_ACTIVITY_SINGLE_TOP. This is the same as android:launchMode="singleTop" when using it alone. If the activity exists and on the top of the task, it won't create a new instance, instead it will call the top activity's onNewIntent().

What is Flag_activity_clear_top?

In a case like that you can set the FLAG_ACTIVITY_CLEAR_TOP flag for the intent, meaning if the activity being launched is already running in the current task (LoginActivity), then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be ...


So my problem is:

  • I start App1, open Screen1 and then Screen2.
  • I press Home, leaving App1 in the background.
  • I open App2, start App1.Screen1 with FLAG_ACTIVITY_NEW_TASK, expecting to be on App1.Screen2 in the previously left task. Instead Im on App1.Screen1 and the system called onNewIntent().

When I press back it brings Sceen2 and Screen1 again. I dont use any other intent flags or launch modes.

Could someone explain what's happening??