Launch Modes In Android
Tags: android
Published: 2021-06-04 06:18:30

Android is a mobile operating system based on a modified version of the Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance and commercially sponsored by Google. It was unveiled in November 2007, with the first commercial Android device, the HTC Dream, being launched in September 2008.

It is free and open-source software; its source code is known as Android Open Source Project (AOSP), which is primarily licensed under the Apache License. However most Android devices ship with additional proprietary software pre-installed, most notably Google Mobile Services (GMS) which includes core apps such as Google Chrome, the digital distribution platform Google Play and associated Google Play Services development platform.

About 70 percent of Android smartphones run Google's ecosystem; competing Android ecosystems and forks include Fire OS (developed by Amazon) or LineageOS. However the "Android" name and logo are trademarks of Google which impose standards to restrict "uncertified" devices outside their ecosystem to use Android branding.

## Launch Mode

The different launch modes in Android are given below:

#### Standard:

* This launch mode generates an activity’s new instance in the task from which it originated.
* It is possible to create several instances for the same activity.
* For Example, suppose our current stack is A -> B -> C. Now, if we launch activity B again with the “standard” launch mode, then the new stack will be A -> B -> C -> B.

#### SingleTop:

* This launch mode is similar to the Standard launch mode except if there exists an activity’s previous instance on the top of the stack, then a new instance will not be created.
* But the intent will be sent to the activity’s existing instance.
* For example, suppose our current stack is A -> B -> C. Now, if we launch the activity B again with “singleTop” launch mode,then the new stack will be A -> B -> C -> B.
* Consider another example, where the current stack is A -> B -> C. Now, if we launch activity C again with the “singleTop” launch mode, then the stack will remain the same i.e., A -> B -> C. The intent will be passed to the onNewIntent() method.

#### SingleTask:

* This launch mode will create a new task and push a new instance to the task as the root.
* For example, suppose our current stack is A -> B -> C -> D. Now, if we launch activity B again with the “singleTask” launch mode, then the new stack will be A -> B. Here, a callback has been received on the old instance and C and D activities are destroyed.

#### SingleInstance:

* This launch mode is similar to the SingleTask launch mode. But the system doesn’t support launching any new activities in the same task.
* In a situation where the new activity is launched, it is launched in a separate task.
* For example, Suppose our current stack is A -> B -> C. Now, if we launch the activity D with the “singleInstance” launch mode, then there will be two stacks:
- A -> B -> C
- D, If you call activity E, then it will be added to the first stack.
- A -> B -> C -> E
- D

Again if you Call the activity D, then it will call the same activity from the 2nd stack and pass the intent to onNewIntent().
Content - [InterviewBit](https://www.interviewbit.com/android-interview-questions/)