I recently made an app that have tons of activities performing different functions so i was wondering, can I create only one activity that changes every time i want it to ,or will that slow my app down?
A task is a collection of activities that users interact with when trying to do something in your app. These activities are arranged in a stack—the back stack—in the order in which each activity is opened. For example, an email app might have one activity to show a list of new messages.
Task affinity lets you define which task an activity belongs to. By default, an activity has the same task affinity as its root activity. With task affinity, we can now separate activities into different tasks.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With