Android Slices — 3W’s

3W’s — What, Why, & Where…

Hemasaicharan Kothamasu
MindOrks
3 min readMar 15, 2019

--

Slices is not slicing a fruit in the Air — Master Shifu

3W’s

Slices — What, Why, & Where

Why does it matter?

It’s a part of Behavior Components

What are Slices?

It’s a UI template to share app data outside of your application.
Google Search and Google Assistant
Jetpack supports all the way back to Android 4.4 (API 19)
Reaching approx. 95% of Android users

How to build Slices…?

Building with focus….

Prerequisites..

Android Studio 3.2
Download and install the Slice Viewer APK
Add the below library dependencies

dependencies {
implementation ‘androidx.slice:slice-core:1.0.0’
implementation ‘androidx.slice:slice-view:1.0.0’
implementation ‘androidx.slice:slice-builders:1.0.0’
}

Where we use Slices…?

Book a cab (or) Enable Mobile data (or) View your gallery

Examples…!

Different use cases to expose app data using Slices…!

Architecture..

Slices Architecture on how it behaves in multiple scenarios…!

How to create Slices…?

Use Slice Provider to create slices

Left: Slice Provider declaration in Manifest / Right: Steps to create Slice Provider

Permissions…!

The way of granting permission using Runtime in java

Slice Templates…!

Small template to expose data using Builder class.

Actions on Slices…!

ex: To perform Action using toggle button to enable or disable something

Display modes…!

Different ways and sizes of displaying data in Slices…

Types of Builders….?

Five different types of builder classes to design slices…!

Header Builder….!

Header building preview with code snippet

GridRow Builder…!

GridRow builder preview with code snippet

Finally Slice Viewer…?

SliceViewer apk and way to run the app….!
Before Run the app to test your slices, we have the Edit the configuration and Add URL to activate Slices…!

At Last Why we have to use Slices…?

It’s absolutely true…!
After learning, I hope you enjoy like this….!
Thank You

--

--

Hemasaicharan Kothamasu
MindOrks

Android developer | Tech geek | GCloud Dev | Flutter developer | AI & ML learner | Actions on Google | Speaker at GDG Hyderabad https://about.me/hemasaicharan