Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

Android Slices: Getting Started

In this tutorial, you'll learn how to use Slices, which allow you to embed parts of your app into viewers like the Google Search app and Google Assistant.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5534-android-slices-getting-started

Hi Tarek, great tutorial! Was wondering how can we use download images in android slices. Would we use isLoading flag ? But when then should be notify the content is now available for display?

Hi @jehandadk
Thank you for that question,

Yes, you have to set isLoading to true in the builder of the delayed content, which is the CellBuilder in the example here.
addImage(null, ListBuilder.SMALL_IMAGE, true) and once your image is downloaded,
call getContentResolver().notifyChange(sliceUri) using your Slice URI. and that will invoke onBindSlice()

BTW, we used notifyChange(sliceUri) in the tutorial to update the notification icon.

Note, some of the content like title and subtitle is annotated as a NonNull object so you need to set a placeholder at least.

For more information about delayed-content, check the official https://developer.android.com/guide/slices/templates#delayed-content

Thank you again! feel free to ask more questions :]

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!