I recently made an app that contains tons of activities performing different functions so I was wondering, can I create only one activity. No fragments nothing, only one activity that changes every time I want it to by maybe making views visible or removing and adding buttons whenever I need them? Or will that slow my app down?
Asked
Active
Viewed 1,027 times
16
-
2Does this answer your question? [One Activity and all other Fragments](https://stackoverflow.com/questions/12154505/one-activity-and-all-other-fragments) – Joundill May 15 '20 at 03:38
-
Yes, that has been the recommended practice for a couple years now. https://android-developers.googleblog.com/2018/05/use-android-jetpack-to-accelerate-your.html?m=1 – Steve M May 03 '20 at 16:34
-
You should try One activity and many fragments approach using [Android Navigation Component](https://developer.android.com/guide/navigation/navigation-getting-started) – May 03 '20 at 17:35
1 Answers
14
No it won't slow your app down. Infact, it is better than having multiple activities in terms of efficiency because laying out and creating a new activity is obviously expensive.
But of course, when it actually makes sense to have 2 activities, you should make two activities because that would make the code more modular, more readable and easily editable.
So you have to strike a balance between efficiency and readability.

Chaitanya Chavali
- 843
- 6
- 12