Your web browser is out of date. Update your browser for more security, speed and the best experience on this site.

Update your browser
CapTech Home Page

Blog May 14, 2018

Exploring Android Slices

At Google IO 2018, Slices were announced as the new approach for remote content. Slices are small, interactive UI templates, similar to widgets, that can be displayed as remote content inside other applications, such as Google Search. Slices provide a means for users to engage with an application in a contextual way, providing functionality and content directly from the app and linking users back to it for more detailed content or actions. Most users do not return to an application after a certain amount of time, so by redirecting the eye of the user at the time they'd be most interested in the application, app owners retain and regain more users.

Key Features

Google provides various templates that can be used together to create the desired functionality. One of the best parts from a development viewpoint is the ability to mix and match different templates to create one specific for each application's features.

Slices also allow for dynamic and updatable content. As the user interacts with the slice, if there is a data change, the slice itself will update based on the changes in real time.

Code Demo

We spent the time after Google IO digging into Slices to try it out for ourselves. Following instructions from the Google IO Session on Slices, and the intial documentation on Slices, we built several sample slices for an app based on two imaginary companies (a hotel chain, and a financial institute). Each company has it's own SliceProvider, and each provider serves up multiple slices, depending on the URI handled by the app. This setup taught us that you can have multiple SliceProviders in a single application.

There's lots of ways the use Slices ─ we experimented with callbacks to Android's BroadcastReceivers, Activities in the app, creating a rating view by showing five stars the user could select and updating the slice from their selection. Whether you're just displaying data, linking back to the app, or updating the slice from relevant information, Slices open a whole new world of possibilites for apps that might otherwise be forgotten by the user.

Check out our demo on GitHub!

Here's a gif of the sample app in action:

app demo


While Slices are not in production right now, Google has announced they will release them along with Android P. They will be backwards compatible with KitKat (through the new AndroidX compatibility library). Slices can still be developed and previewed through a test app, Slice Viewer, which displays app Slices similarly to how Google Search might. Setting up the slices as run configurations as seen in the Getting Started guide proved to be very helpful over the course of testing this demo application. We noticed that the Slice Viewer sometimes does not update its UI when testing a new Slice, but you can force close the application and run it again to get around this issue.

Lessons Learned

There were many benefits discovered while exploring Slices. From a user's perspective, the app can have functionality and visibility outside of itself and the user can perform actions without ever entering the app. The Slices themselves look great; and since they are uniform and well structured through templates, they will also agree well with Slices from other applications. From a developer's viewpoint, the templates are easy to learn, customizable, and straightforward to combine in new and different ways. The code samples provided by Google gives developers a nice head start on structuring their Slices. In addition, existing Intents and Content Providers make providing userful actions and content quick and easy. This allows for features like deep linking to work well with Slices.

There are a few drawbacks and restrictions. The templates are quite strict on layout of different texts, buttons, and actions. Users should not expect to have the ability to provide precise positioning or layout exactly to their liking. The functionality behind the layout also does some work of its own. For instance, if a user forgets to add an action to something, it might use an action attached to a different part of the template.

The biggest drawback at the time of this writing is Slices are not production ready yet and documentation is sparse. There was much experimentation and small delays before everything was finally working properly. You can read more about these issues in the README of the demo app.

What's Next

There is huge potential for a wide variety of use cases when thinking about the future with Slices. In the demo, hotels and financial institutions were the focus, but Slices can be applied to many more industries.

The possibility of what's to come is exciting. Google announced at IO that they are currently exploring Push, Long Press, and Home Screen functionality as well as other platforms.

There are also some unanswered questions that we think will become apparent or documented with the official release of Slices, such as:

  • How will Slices be mapped to actions?
  • How will a Slice will be chosen and presented from Google search?
  • How will two apps that both provide Slices be shown when they both match a search term (is some of that tied to Google prediction, perhaps)?

We'll follow up when answers to these questions become available. In the meantime - ask yourself how Slices can give YOUR app a boost!