romannurik edited this page Dec 10, 2014 · 7 revisions

This page: api.muzei.co

Muzei offers two API surfaces:

  1. A simple API that allows you to build your own wallpaper source.
  2. A content provider contract that allows you to read current artwork data.

Building your own wallpaper source

It's pretty easy to get started with building your own wallpaper source:

  1. If you're using Gradle or Maven, simply add the following Maven coordinates as a dependency: com.google.android.apps.muzei:muzei-api:+. Otherwise, simply add the API JAR (and optional Javadoc/sources JARs) to your Android project.
  2. Create a new service that extends either the MuzeiArtSource or RemoteMuzeiArtSource class.
  3. Add the corresponding <service> tag to your AndroidManifest.xml file and add the required <intent-filter> and <meta-data> elements.

Once you have both Muzei and your custom source installed, you should be able to choose your source in the Muzei customization screen.

A deeper discussion of the API, along with code snippets, is available in the MuzeiArtSource class reference.

Sample code

A complete example is available in the example-source-500px directory.


Accessing current wallpaper information (API 2.0+)

You can access the current wallpaper on Android phones and tablets, or on Android Wear, while Muzei is the active wallpaper. The Muzei phone/tablet app includes a wearable APK that exposes the API on Android Wear.

  1. If you're using Gradle or Maven, simply add the following Maven coordinates as a dependency: com.google.android.apps.muzei:muzei-api:2.+. Otherwise, simply add the API JAR (and optional Javadoc/sources JARs) to your Android project.
  2. Use either MuzeiContract.Artwork.getCurrentArtworkBitmap() to get the current artwork as a bitmap, or access more information about the artwork by querying MuzeiContract.Artwork.CONTENT_URI with a ContentResolver.
  3. Register a broadcast receiver for the com.google.android.apps.muzei.ACTION_ARTWORK_CHANGED action to listen for artwork changes.

A deeper discussion of the API, along with code snippets, is available in the MuzeiContract.Artwork class reference.

Sample code

Complete examples are available in the example-contract-widget and example-watchface directories.


API reference

The full API reference for both API surfaces is available here.


Changelog

API v2.0: December 10, 2014

  • Added contract API.
  • A number of stability improvements to the art source API.

API v1.0: February 12, 2014

  • Initial API release.
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.