Consider the following code:
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
What best explains the code above?
Consider the following code:
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
What best explains the code above?
The code is using the FLAG_ACTIVITY_CLEAR_TOP flag with the Intent. This means that if the activity being launched is already running in the current task, instead of launching a new instance of that activity, all the other activities present on top of it in the stack will be closed. The existing instance of that activity will then receive the new Intent.
A. The activity being launched is already running in the current task, 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 delivered to the (now on top) old activity as a new Intent.