muzei-api / com.google.android.apps.muzei.api

Package com.google.android.apps.muzei.api

Contains the MuzeiContract APIs to get the current artwork from Muzei.

The MuzeiContract provides access to information about the current wallpaper via MuzeiContract.Artwork and about the current source via MuzeiContract.Sources.

Each of these contracts provide only read access to Muzei's android.content.ContentProvider and therefore provide you with a content URI and set of columns for working directly with the underlying tables via a android.content.ContentResolver.

Listening for changes

It is strongly recommended to listen for changes rather than repeatedly query Muzei's API. If you only need to listen for changes while your process is alive, you can use android.content.Context.registerReceiver with either of the CONTENT_URI Uris.

If you instead need to continually monitor Muzei for changes even while your app is in the background or not in memory, you must use an alternate approach. On API 24 and higher devices, you should use WorkManager and addContentUriTrigger() to trigger your work when Muzei updates.

To support devices running API 23 or earlier (where listening for content URIs in the background is not possible), Muzei provides an ACTION_ constant for each table that allows you register a android.content.BroadcastReceiver that will be triggered every time Muzei changes.

Types

Artwork

An object representing a single artwork retrieved from the MuzeiContract.Artwork table.

class Artwork

MuzeiContract

Contract between Muzei and applications, containing the definitions for all supported URIs and columns as well as helper methods to make it easier to work with the provided data.

object MuzeiContract

UserCommand

Data class representing a user-visible command.

data class UserCommand

Functions

createChooseProviderIntent

Deep link into Muzei's Sources screen, automatically scrolling to the com.google.android.apps.muzei.api.provider.MuzeiArtProvider associated with this ProviderClient. If Muzei is not yet activated, users will be asked to activate Muzei before continuing onto the Sources screen.

fun ProviderClient.createChooseProviderIntent(): Intent

isSelected

Checks the MuzeiContract.Sources table provided by Muzei to determine whether the com.google.android.apps.muzei.api.provider.MuzeiArtProvider associated with this ProviderClient has been selected by the user.

fun ProviderClient.isSelected(context: Context): Boolean