DEV Community

Discussion on: Don’t write Android apps like it’s 2009!

Collapse
 
devilmehoney profile image
Me

Instead of using tons of activities, use fragments that can be retained so on screen rotation we avoid creating elements, just put on front, for example.

Collapse
 
mgazar_ profile image
Mostafa Gazar

Even though Fragments have some shortcomings it is still a good idea to use them. This could work out great for you if you want to support different form factors in the future (phones, tablets, chromebooks, ....).

That said Fragments will not retain much on config changes (screen rotation for example) to handle state there are a few options out there, I would recommend Lifecycles with ViewModel