When to use a Fragment instead of an Activity

Asked

Viewed 586 times

0

I’m working on a project where I’m making use of several fragments and only one activity. Giving a researched, I saw that many places suggest the use of fragments when the code of the same will be reused and therefore I wondered where I should use fragments and where it would be more interesting to use activities.

The flow of my project follows as follows;

Tela de login > Tela de lista > tela de inserção de item na lista
                              > tela de visualização de item da lista
                              > tela de itens removidos da lista > tela de visualização de itens removidos da lista
                              > tela de relatórios

I do not know if it was clear the flowchart, at the moment I have no program to do something more suitable. In my case, there is only one activity on all these screens, and of these only the visualization screens are reused (same fragment). All the others are fragments which, despite being used constantly, are not reused.

My question is: where, in this scenario, is the best use of activities in place of fragments?

1 answer

1


It is considered good practice to use Activity in the case of a single stream, for example, say that inside the editing screen of the Voce item put the option of the user to select an icon for that item, the flow that Voce would do after that would be a unique path (the user could select images that Oce added to the application or select an image from the gallery). This selection screen is only accessible from the item addition screen in the list, not being reused by any other. Another important point is that Voce does not want that during the icone selection the user goes to the screen of the list of items already created or to the reports, Voce wants the user to finish selecting the item or cancel the operation(You don’t need to be saving the state of her once she has concluded what she is doing).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.