Over a million developers have joined DZone.

Flow and Mortar: Libraries to Simplify Android Activities and Fragments

DZone's Guide to

Flow and Mortar: Libraries to Simplify Android Activities and Fragments

· Java Zone
Free Resource

Try Okta to add social login, MFA, and OpenID Connect support to your Java app in minutes. Create a free developer account today and never build auth again.

We recently heard about Square's Flow as a solution for Android-induced development headaches, and it's a pretty interesting tool that looks like it could do a lot to speed up some of the uglier parts of Android development. Flow is a library that helps Android developers keep track of what view an app should be showing using view instances, and aims to simplify some of the confusion that came with Android's Activities and Fragments. According to the Square's overview:

[Flow] is a backstack model that knows you likely have to deal both with the device's back button as well as an ActionBar's up button. The things that Flow manages are referred to as "screens," with a lowercase "S" — they're not instances of any particular class. To Flow a screen is a POJO that describes a particular location in your app. Think of it as a URL, or an informal Intent.

Along with Flow, Square has built a library called Mortar that determines what happens when Flow takes you to a new view. 

To see how it all works, Square's overview also includes a walkthrough of building a music player app with album and track screens, complete with explanations of the roles of Flow and Mortar, as well as code samples of implementation.

Build and launch faster with Okta’s user management API. Register today for the free forever developer edition!


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}