As a developer, we are working in the field of Android application development for a long time and Activity is the most familiar thing to us. It is the first component among the other major components that we have used earlier in the field of Android, hence the familiarity.
Now, the word “Activity” may not sound familiar to most people, as we are much concerned about the software that we will use in our smartphone than knowing its dynamic behaviours and functionalities in the background.
We, often use the word “page” when we use any Android application, for example, “After filling up the details please, click on the ‘Next’ button’ and go to the next page in the application”. The word page is nothing but technically referring to “Activity”. As the complexity of the application increases, the number of Activities also increases.
In 2018, Google first announces the release of the Jetpack library at their Annual Developers Conference. Along with the Jetpack, they had also spoken about the term “Single Activity Architecture” and it seems similar architecture will be preferred in future.
It is an architecture that must consist of one Activity or in some cases relatively small number of activities. So, we need to know how this architecture works.
Earlier when we use to declare multiple activities in our projects, where each one of them was used to represent on front-end or UI (User Interface). Instead, in this architecture, we define an Activity as a container and multiple Fragments inside that Activity will represent the User Interface.
As we have already discussed the benefits, it’s our suggestion to the future Android Developer to switch into Single Activity Architecture using Navigation Components.
For example, we are working on an authentication module in any application. Instead of using multiple activities for login and registration, we can simply approach this architecture by creating fragments for every module for authentication and then bound them in a Single activity. It also provides the mobility to switch between the fragments and increase the stability of the application.