'How do I best control activity flow?

I am tasked with building an app that does not have a fixed screen order. When started the app will contact a server an get a list of actions to perform. So one launch could be screen 1 - screen 5 - screen 7 next time screen 3 - screen 5 - screen 9

I tested a simple app that does that; my Main activity starts the needed activity and that activity returns to the main activity, which starts the next needed activity. In other words, all activities return to the Main activity which then determines which activity to start next. It seems to work fine, but I have read that Activities should only be used for UI, my Main activity had no UI, it just controlled which activity happened next. So should I be using a different approach?

I am brand new to Android, but have decades of Java experience. In case it makes a difference, I am using AS 3.0.1 Thanks



Solution 1:[1]

I'd suggest one activity and implementing your "screens" as fragments. This makes it really easy to code your logic for what screen comes next. You are just adding / replacing fragments and not starting and tracking result codes of activities. The business logic for each screen can still be fully encapsulated in the fragment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeffrey Blattman