Engage SDK Listen: Third-party technical integration instructions

Google is building an on-device surface that organizes users' apps by verticals and enables a new immersive experience for personalized app content consumption and discovery. This fullscreen experience provides developer partners with an opportunity to showcase their best rich content in a dedicated channel outside of their app.

This guide contains instructions for developer partners to integrate their audio content, using the Engage SDK to populate both this new surface area and existing Google surfaces.

Integration detail

Terminology

This integration includes the following three cluster types: Recommendation, Continuation, and Featured.

  • Recommendation clusters show personalized suggestions for content to read from an individual developer partner.

    Your recommendations take the following structure:

    • Recommendation Cluster: A UI view that contains a group of recommendations from the same developer partner.

      Figure 1. Entertainment Space UI showing a Recommendation Cluster from a single partner.
    • Entity: An object representing a single item in a cluster. An entity can be a playlist, an audiobook, a podcast, and more. See the Provide entity data section for a list of supported entity types.

      Figure 2. Entertainment Space UI showing a single Entity within a single partner's Recommendation Cluster.
  • The Continuation cluster shows audio content recently engaged by users from multiple developer partners in a single UI grouping. Each developer partner will be allowed to broadcast a maximum of 10 entities in the Continuation cluster.

    Figure 3. Entertainment Space UI showing a Continuation cluster with unfinished recommendations from multiple partners (only one recommendation is currently visible).
  • The Featured cluster showcases a selection of items from multiple developer partners in a single UI grouping. There will be a single Featured cluster, which will be surfaced near the top of the UI with a priority placement above all Recommendation clusters. Each developer partner will be allowed to broadcast up to 10 entities in the Featured cluster.

    Figure 4. Entertainment Space UI showing a Featured cluster with recommendations from multiple partners (only one recommendation is currently visible).

Pre-work

Minimum API level: 19

Add the com.google.android.play:engage library to your app:

dependencies {
    // Make sure you also include that repository in your project's build.gradle file.
    implementation 'com.google.android.play:engage:1.5.0-alpha'
}

To make the Engage SDK function for devices with Android 11 and above, declare the following in the manifest file:

<queries>
   <package android:name="com.android.vending" />
</queries>

Summary

The design is based on an implementation of a bound service.

The data a client can publish is subject to the following limits for different cluster types:

Cluster type Cluster limits Maximum entity limits in a cluster
Recommendation Cluster(s) At most 5 At most 50
Continuation Cluster At most 1 At most 10
Featured Cluster At most 1 At most 10

Step 1: Provide entity data

The SDK has defined different entities to represent each item type. We support the following entities for the Listen category:

  1. MusicAlbumEntity
  2. MusicArtistEntity
  3. MusicTrackEntity
  4. MusicVideoEntity
  5. PlaylistEntity
  6. PodcastSeriesEntity
  7. PodcastEpisodeEntity
  8. LiveRadioStationEntity
  9. AudiobookEntity

The charts below outline available attributes and requirements for each type.

MusicAlbumEntity

The MusicAlbumEntity object represents a music album (for example, Midnights by Taylor Swift).

Attribute Requirement Notes
Name Required The title of the music album.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Info page uri Required The deep link to the provider app for details about the music album.
Playback uri Optional A deep link that starts playing the album in the provider app.
Description Optional Must be within 200 characters if provided.
Artists Required List of artists in the music album.
Songs count Required The number of songs in the music album.
Genres Optional List of genres in the music album.
Music labels Optional List of music labels associated with the album.
Content rating Optional List of content ratings for the album.
Release date Optional The release date of the album in epoch milliseconds.
Duration Optional The duration of the album in milliseconds.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

MusicArtistEntity

The MusicArtistEntity object represents a music arist (for example, Adele).

Attribute Requirement Notes
Name Required Name of the music artist.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Info page uri Required The deep link to the provider app for details about the music artist.
Playback uri Optional The deep link which starts playing the artist's songs in the provider app.
Description Optional Must be within 200 characters if provided.
Album count Optional Integer > 0 if provided.
Singles count Optional Integer > 0 if provided.
Subscribers count Optional Integer > 0 if provided.
Genres Optional List of genres of the musical artist.
Music labels Optional List of music labels associated with the artist.
Content rating Optional List of content ratings of the artist.
Last engagement time Conditionally required Must be provided when the entity is in the Continuation cluster. In epoch milliseconds.

MusicTrackEntity

The MusicTrackEntity object represents a music track (for example, Yellow by Coldplay).

Attribute Requirement Notes
Name Required Title of the music track.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Playback uri Required A deep link that starts playing the music track in the provider app.
Info page uri Optional A deep link to the provider app for details about the music track.
Description Optional Must be within 200 characters if provided.
Duration Required The duration of the track in milliseconds.
Album Optional The name of the album to which the song belongs.
Artists Optional List of artists for the music track.
Genres Optional List of genres for the music track.
Music labels Optional List of music labels associated with the track.
Content rating Optional List of content ratings for the track.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

MusicVideoEntity

The MusicVideoEntity object represents a music video (for example, The Weeknd - Take My Breath (Official Music Video)).

Attribute Requirement Notes
Name Required Title of the music video.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Playback uri Required A deep link that starts playing the music video in the provider app.
Info page uri Optional A deep link to the provider app for details about the music video.
Duration Required The duration of the video in milliseconds.
View count Optional The number of views on the video in free text format.
Artists Optional List of artists of the music video.
Content rating Optional List of content ratings of the track.
Description Optional Must be within 200 characters if provided.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

PlaylistEntity

The PlaylistEntity object represents a music playlist (for example, the US Top 10 Playlist).

Attribute Requirement Notes
Name Required Title of the playlist.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Playback uri Required A deep link that starts playing the music playlist in the provider app.
Info page uri Optional A deep link to the provider app for details about the music playlist.
Duration Required The duration of the playlist in milliseconds.
Songs count Required The number of songs in the music playlist.
Artists Optional List of artists of the music playlist.
Content rating Optional List of content ratings of the playlist.
Description Optional Must be within 200 characters if provided.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

PodcastSeriesEntity

The PodcastSeriesEntity object represents a podcast series (for example, This American Life).

Attribute Requirement Notes
Name Required Title of the podcast series.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Info page uri Required A deep link to the provider app for details about the podcast series.
Playback uri Optional A deep link that starts playing the podcast series in the provider app.
Episode count Required The number of episodes in the podcast series.
Production name Required The name of the production of the podcast series.
Hosts Optional List of hosts of the podcast series.
Genres Optional List of genres of the podcast series.
Downloaded on device Optional Boolean indicating if the podcast is downloaded on the device.
Content rating Optional List of content ratings of the podcast series.
Description Optional Must be within 200 characters if provided.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.

PodcastEpisodeEntity

The PodcastEpisodeEntity object represents a podcast series (for example, Spark Bird, Episode 754: This American Life).

Attribute Requirement Notes
Name Required Title of the podcast episode.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Playback uri Required A deep link that starts playing the podcast episode in the provider app.
Info page uri Optional A deep link to the provider app for details about the podcast episode.
Production name Required The name of the production of the podcast series.
Production series title Required The name of the podcast series to which the episode belongs.
Duration Required The duration of the podcast episode in milliseconds.
Episode index Optional The index of the episode in the series (first index is 1).
Hosts Optional List of hosts of the podcast episode.
Genres Optional List of genres of the podcast episode.
Downloaded on device Optional Boolean indicating if the podcast episode is downloaded on the device.
Content rating Optional List of content ratings of the podcast episode.
Description Optional Must be within 200 characters if provided.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

LiveRadioStationEntity

The LiveRadioStationEntity object represents a live radio station (for example, 98.1 The Breeze).

Attribute Requirement Notes
Name Required Title of the live radio station.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Playback uri Required A deep link that starts playing the radio station in the provider app.
Info page uri Optional A deep link to the provider app for details about the radio station.
Frequency Required The frequency at which the radio station is broadcasted (for example, "98.1 FM").
Show title Optional The current show that is playing on the radio station.
Hosts Optional List of hosts of the radio station.
Description Optional Must be within 200 characters if provided.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

AudiobookEntity

The AudiobookEntity object represents an audiobook (for example, the audiobook of Becoming by Michelle Obama).

Attribute Requirement Notes
Name Required The name of the audio book.
Poster images Required At least one image must be provided. See Image Specifications for guidance.
Author Required At least one author name must be provided.
Narrator Required At least one narrator name must be provided.
Action link uri Required The deep link to the provider app for the audiobook.
Publish date Optional In epoch milliseconds if provided.
Description Optional Must be within 200 characters if provided.
Price Optional Free text
Duration Optional Must be a positive value if provided.
Genre Optional List of genres associated with the book.
Series name Optional Name of the series that the audiobook belongs to (for example, Harry Potter).
Series unit index Optional The index of the audiobook in the series, where 1 is the first audiobook in the series. For example, if Harry Potter and the Prisoner of Azkaban is the 3rd book in the series, this should be set to 3.
Author Required At least one author name must be provided.
Last engagement time Conditionally required Must be provided when the item is in the Continuation cluster. In epoch milliseconds.
Progress percentage complete Conditionally required Must be provided when the item is in the Continuation cluster. Integer between 0 and 100.

Image specifications

Required specifications for image assets are listed below:

Aspect ratio Requirement Minimum pixels Recommended pixels
Square (1x1) Required 300x300 1200x1200
Landscape (1.91x1) Optional 600x314 1200x628
Portrait (4x5) Optional 480x600 960x1200

File formats

PNG, JPG, static GIF, WebP

Maximum file size

5120 KB

Additional recommendations

  • Image safe area: Put your important content in the center 80% of the image.

Examples

MusicAlbumEntity musicAlbumEntity =
        new MusicAlbumEntity.Builder()
            .setName(NAME)
             .addPosterImage(new Image.Builder()
                  .setImageUri(Uri.parse("http://www.x.com/image.png"))
                  .setImageHeightInPixel(960)
                  .setImageWidthInPixel(408)
                  .build())
            .setPlayBackUri("https://play.google/album/play")
            .setInfoPageUri("https://play.google/album/info")
            .setDescription("A description of this album.")
            .addArtist("Artist")
            .addGenre("Genre")
            .addMusicLabel("Label")
            .addContentRating("Rating")
            .setSongsCount(960)
            .setReleaseDateEpochMillis(1633032895L)
            .setDurationMillis(1633L)
            .build();
AudiobookEntity audiobookEntity =
        new AudiobookEntity.Builder()
            .setName("Becoming")
            .addPosterImage(new Image.Builder()
                 .setImageUri(Uri.parse("http://www.x.com/image.png"))
                 .setImageHeightInPixel(960)
                 .setImageWidthInPixel(408)
                  .build())
            .addAuthor("Michelle Obama")
            .addNarrator("Michelle Obama")
            .setActionLinkUri(
               Uri.parse("https://play.google/audiobooks/1"))
            .setDurationMillis(16335L)
            .setPublishDateEpochMillis(1633032895L)
            .setDescription("An intimate, powerful, and inspiring memoir")
            .setPrice("$16.95")
            .addGenre("biography")
            .build();

Step 2: Provide Cluster data

It’s recommended to have the content publish job executed in the background (for example, using WorkManager) and scheduled on a regular basis or on an event basis (for example, every time the user opens the app or when the user just added something to their cart).

AppEngagePublishClient is responsible for publishing clients. There are five APIs to publish clusters in the client:

  • isServiceAvailable
  • publishRecommendationClusters
  • publishFeaturedCluster
  • publishContinuationCluster
  • deleteClusters

API #1: isServiceAvailable

This API is used to check if the service is available for integration and whether the content can be presented on the device.

Task<Boolean> isAvailableTask = client.isServiceAvailable();

isAvailableTask.addOnCompleteListener(task - > {
    if (resultTask.isSuccessful()) {
        // Handle success
    }
});

API #2: publishRecommendationClusters

This API is used to publish a list of RecommendationCluster objects.

Task<Void> task =
        client.publishRecommendationClusters(
            new PublishRecommendationClustersRequest.Builder()
                .addRecommendationCluster(
                    new RecommendationCluster.Builder()
                        .addEntity(entity1)
                        .addEntity(entity2)
                        .setTitle("recommendation")
                        .build())
                .build());

When the service receives the request, the following actions take place within one transaction:

  • Existing RecommendationCluster data from the developer partner is removed.
  • Data from the request is parsed and stored in the updated Recommendation Cluster.

In case of an error, the entire request is rejected and the existing state is maintained.

API #3: publishFeaturedCluster

This API is used to publish a list of FeaturedCluster objects.

Task<Void> task =
        client.publishFeaturedCluster(
            new PublishFeaturedClustersRequest.Builder()
                .addFeaturedCluster(
                    new FeaturedCluster.Builder()
                        .addEntity(entity1)
                        .addEntity(entity2)
                        .build())
                .build());

When the service receives the request, the following actions take place within one transaction:

  • Existing FeaturedCluster data from the developer partner is removed.
  • Data from the request is parsed and stored in the updated Featured Cluster.

In case of an error, the entire request is rejected and the existing state is maintained.

API #4: publishContinuationCluster

This API is used to publish a ContinuationCluster object.

Task<Void> task =
        client.publishContinuationCluster(
            new PublishContinuationClusterRequest.Builder()
                .setContinuationCluster(
                    new ContinuationCluster.Builder()
                        .addEntity(entity1)
                        .addEntity(entity2)
                        .build())
                .build());

When the service receives the request, the following actions take place within one transaction:

  • Existing ContinuationCluster data from the developer partner is removed.
  • Data from the request is parsed and stored in the updated Continuation Cluster.

In case of an error, the entire request is rejected and the existing state is maintained.

API #5: deleteClusters

This API is used to delete the content of a given cluster type.

Task<Void> task =
     client.deleteClusters(
            new DeleteClustersRequest.Builder()
                .addClusterType(ClusterType.TYPE_CONTINUATION)
                .addClusterType(ClusterType.TYPE_FEATURED)
                .addClusterType(ClusterType.TYPE_RECOMMENDATION)
                .build());

When the service receives the request, it removes the existing data from all clusters matching the specified cluster types. Clients can choose to pass one or many cluster types. In case of an error, the entire request is rejected and the existing state is maintained.

Error handling

It is highly recommended to listen to the task result from the publish APIs such that a follow-up action can be taken to recover and resubmit an successful task.

client.publishRecommendationClusters(
              new PublishRecommendationClustersRequest.Builder()
                  .addRecommendationCluster(...)
                  .build())
          .addOnCompleteListener(
              task -> {
                if (task.isSuccessful()) {
                  // do something
                } else {
                  Exception exception = task.getException();
                  if (exception instanceof AppEngageException) {
                    @AppEngageErrorCode
                    int errorCode = ((AppEngageException) exception).getErrorCode();
                    if (errorCode == AppEngageErrorCode.SERVICE_NOT_FOUND) {
                      // do something
                    }
                  }
                }
              });

The error is returned as an AppEngageException with the cause included as an error code.

Error code Note
SERVICE_NOT_FOUND The service is not available on the given device.
SERVICE_NOT_AVAILABLE The service is available on the given device, but it is not available at the time of the call (for example, it is explicitly disabled).
SERVICE_CALL_EXECUTION_FAILURE The task execution failed due to threading issues. In this case, it can be retried.
SERVICE_CALL_PERMISSION_DENIED The caller is not allowed to make the service call.
SERVICE_CALL_INVALID_ARGUMENT The request contains invalid data (for example, more than the allowed number of clusters).
SERVICE_CALL_INTERNAL There is an error on the service side.
SERVICE_CALL_RESOURCE_EXHAUSTED The service call is made too frequently.

Step 3: Handle broadcast intents

In addition to making publish content API calls through a job, it is also required to set up a BroadcastReceiver to receive the request for a content publish.

The goal of broadcast intents is mainly for app reactivation and forcing data sync. Broadcast intents are not designed to be sent very frequently. It is only triggered when the Engage Service determines the content might be stale (for example, a week old). That way, there is more confidence that the user can have a fresh content experience, even if the application has not been executed for a long period of time.

The BroadcastReceiver must be set up in the following two ways:

  • Dynamically register an instance of the BroadcastReceiver class using Context.registerReceiver(). This enables communication from applications that are still live in memory.
class AppEngageBroadcastReceiver extends BroadcastReceiver {
// Trigger recommendation cluster publish when PUBLISH_RECOMMENDATION broadcast
// is received

// Trigger featured cluster publish when PUBLISH_FEATURED broadcast is received

// Trigger continuation cluster publish when PUBLISH_CONTINUATION broadcast is
// received
}

public static void registerBroadcastReceivers(Context context) {

context = context.getApplicationContext();

// Register Recommendation Cluster Publish Intent
context.registerReceiver(new AppEngageBroadcastReceiver(),
new IntentFilter(com.google.android.play.engage.service.Intents.ACTION_PUBLISH_RECOMMENDATION));

// Register Featured Cluster Publish Intent
context.registerReceiver(new AppEngageBroadcastReceiver(),
new IntentFilter(com.google.android.play.engage.service.Intents.ACTION_PUBLISH_FEATURED));


// Register Continuation Cluster Publish Intent
context.registerReceiver(new AppEngageBroadcastReceiver(),
new IntentFilter(com.google.android.play.engage.service.Intents.ACTION_PUBLISH_CONTINUATION));

}
  • Statically declare an implementation with the <receiver> tag in your AndroidManifest.xml file. This allows the application to receive broadcast intents when it is not running, and also allows the application to publish the content.
<application>
   <receiver
      android:name=".AppEngageBroadcastReceiver"
      android:exported="true"
      android:enabled="true">
      <intent-filter>
         <action android:name="com.google.android.play.engage.action.PUBLISH_RECOMMENDATION" />
      </intent-filter>
      <intent-filter>
         <action android:name="com.google.android.play.engage.action.PUBLISH_FEATURED" />
      </intent-filter>
      <intent-filter>
         <action android:name="com.google.android.play.engage.action.PUBLISH_CONTINUATION" />
      </intent-filter>
   </receiver>
</application>

The following intents will be sent by the service:

  • com.google.android.play.engage.action.PUBLISH_RECOMMENDATION It is recommended to start a publishRecommendationClusters call when receiving this intent.
  • com.google.android.play.engage.action.PUBLISH_FEATURED It is recommended to start a publishFeaturedCluster call when receiving this intent.
  • com.google.android.play.engage.action.PUBLISH_CONTINUATION It is recommended to start a publishContinuationCluster call when receiving this intent.

Integration workflow

For a step-by-step guide on verifying your integration after it is complete, see Engage developer integration workflow.

FAQs

See Engage SDK Frequently Asked Questions for FAQs.

Contact

Please contact engage-developers@google.com if there are any questions during the integration process. Our team will reply as soon as possible.

Next steps

After completing this integration, your next steps are as follows:

  • Send an email to engage-developers@google.com and attach your integrated APK that is ready for testing by Google.
  • Google will perform a verification and review internally to make sure the integration works as expected. If changes are needed, Google will contact you with any necessary details.
  • When testing is complete and no changes are needed, Google will contact you to notify you that you can start publishing the updated and integrated APK to the Play Store.
  • After Google has confirmed that your updated APK has been published to the Play Store, your Recommendation, Featured, and Continuation clusters will be published and visible to users.