# Back to basics: Plugging in the Activity

DevFeed: [Back to basics: Plugging in the Activity](<https://devfeed.tech/articles/back-to-basics-plugging-in-the-activity-26000.md>)

Original publisher: [Read original article](<https://medium.com/@nhaarman/back-to-basics-plugging-in-the-activity-cc1e6a7f0ea4?source=rss-fceb7a60a849------2>)

Author: Niek Haarman

Published: 2019-01-28T23:06:32Z

Content type: tutorial

Language: en

Sources: [Stories by Niek Haarman on Medium](<https://devfeed.tech/sources/stories-by-niek-haarman-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [Application Development](<https://devfeed.tech/topics/application-development.md>), [Development](<https://devfeed.tech/topics/development.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Logging](<https://devfeed.tech/topics/logging.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [application-development](<https://devfeed.tech/tags/application-development.md>), [development](<https://devfeed.tech/tags/development.md>), [logging](<https://devfeed.tech/tags/logging.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [navigation-architecture](<https://devfeed.tech/tags/navigation-architecture.md>), [testing](<https://devfeed.tech/tags/testing.md>), [user-interface](<https://devfeed.tech/tags/user-interface.md>)

## AI overview

This tutorial explains how to use an Android Activity as a pluggable window for displaying screens managed by a composable navigator tree. It contrasts this approach with traditional multi-Activity applications, single-Activity applications using Fragments, and the Navigation Architecture Component.

## Source excerpt

...and wrapping up this series. In previous articles, I wrote about how you can create screens and navigators as composable building blocks for your application. Screens become little independent blocks of code that take input and produce an output, navigators tie these screens together by providing the input and listening for the output. Navigators in turn can be composable as well and accept input and provide output. In the end, you may end up with a tree of navigators with screens at their leafs. An example of navigation through an application where the user registers and enters the main application flow. See Back to basics: Navigation for more information. At the root of the tree, this leaves us with a stream of active screens which we can use for several things, like for testing, analytics or logging. But above all, this leaves us with a perfect hook to provide the user interface! Presenting screens In traditional Android application development, an Activity represented a single screen. To navigate to a different screen, you would start a new Activity and the OS would add it to a back stack for you. Activities have their own lifecycles and deal with their own layout. Unfortunately, the Activity class is a God class, and quickly leads to messy implementations. Over the years a lot of developers have switched to so called 'single Activity' applications, where the app would utilize a single Activity class to host the entire application flow. The most straightforward way to do this is using Fragments and the back stack in the FragmentManager. More recently, the Navigation Architecture Component provides another way to implement a single Activity application. Fragments however are just as messy as their Activity counter parts. In fact, Fragments are designed to be able to do everything an Activity can do! Displaying screens Instead, we can take our Activity instance and treat it as nothing more than a window that can display a user interface. It registers a listener w