Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create only one activity that handles the whole app? [duplicate]

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?

like image 499
Varrox Systems Avatar asked May 03 '20 16:05

Varrox Systems


People also ask

What is a task Backstack?

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.

What is task affinity?

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.


1 Answers

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.

like image 146
Chaitanya Chavali Avatar answered Sep 21 '22 19:09

Chaitanya Chavali