# Everything that's wrong with Android's Activities

DevFeed: [Everything that's wrong with Android's Activities](<https://devfeed.tech/articles/everything-that-s-wrong-with-android-s-activities-26002.md>)

Original publisher: [Read original article](<https://medium.com/@nhaarman/everything-thats-wrong-with-android-s-activities-ee784a84d775?source=rss-fceb7a60a849------2>)

Author: Niek Haarman

Published: 2018-08-27T19:38:46Z

Content type: opinion

Language: en

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

Topics: [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-framework](<https://devfeed.tech/tags/android-framework.md>), [animations](<https://devfeed.tech/tags/animations.md>), [apps](<https://devfeed.tech/tags/apps.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [layout](<https://devfeed.tech/tags/layout.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [memory](<https://devfeed.tech/tags/memory.md>), [multitasking](<https://devfeed.tech/tags/multitasking.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [orientation](<https://devfeed.tech/tags/orientation.md>), [resources](<https://devfeed.tech/tags/resources.md>), [restoration](<https://devfeed.tech/tags/restoration.md>), [state](<https://devfeed.tech/tags/state.md>), [user-experience](<https://devfeed.tech/tags/user-experience.md>), [window](<https://devfeed.tech/tags/window.md>)

## AI overview

The excerpt argues that Android Activities combine too many responsibilities: hosting UI, lifecycle and state restoration, navigation, permissions, menus, input, and other framework tasks. This violates the single responsibility principle and can entangle screen and business logic with configuration changes and Android-specific behavior; multi-Activity apps also make fine-grained screen transition control difficult. It proposes keeping an Activity's role simple--hosting the UI--and treating framework-facing pieces such as the GUI and database as plugins at the system boundary. Navigation, presenters, and other application logic should remain separate and testable, so framework or library workarounds do not require changes to core logic. The excerpt notes that this is an architectural recommendation, while Android's framework still requires developers to work with Activities and Fragments.

## Source excerpt

..and Fragments, for that matter. Let's just kick off and have a look at what an Activity is capable of: 1. The Activity is an entry point The Activity is an entry point into your application that the user sees when they open your application. Upon clicking your application icon from a launcher app, an Activity instance is created and presented to the user. 2. The Activity hosts the window that interacts with the user. By calling setContentView in your Activity, you can inflate a layout that is bound to a Window instance hosted by the Activity. This allows the user to see and interact with your application. 3. The Activity has a lifecycle Android's multitasking mechanism allows for applications to be put in the background temporarily, and navigated back to when the user sees fit. To be able to react to these events, the Activity provides a set of callbacks you can implement. 4. The Activity needs state restoration Android's multitasking mechanism combined with limited memory can cause applications to be killed. To prevent a bad user experience when the user loses a message he or she was typing due to this, the Activity allows its state to be saved to a bundle. 5. An Activity can have a result Applications can start other applications to request a particular result. For example, the Contacts app can be launched to select a particular contact. When this is done, the result is sent back to the original application that started the request. Now these are all very valid use cases. They make up the foundation of all applications, and allow for perfectly fine applications to be created. But wait, there's more! 6. The Activity is destroyed on configuration changes When a device configuration changes, such as an orientation change or when the system local has changed, the Activity is destroyed and recreated with a new Resources set for the new configuration. 7. The Activity handles navigation When a user clicks an item in an item list Activity, the Activity can start a new A