This guide explains how to read media notifications from our Android app into your own app.


If you are developing an Android application and want to know what is happening in the Spotify app, you can subscribe to broadcast notifications from it. The Spotify app can posts sticky media broadcast notifications that can be read by any app on the same Android device. The media notifications contain information about what is currently being played in the Spotify App, as well as the playback position and the playback status of the app.

Note that media notifications need to be enabled manually in the Spotify app; see Enabling Media Notifications below.


This example code shows how to read media notifications. For it to work, the app must first create a broadcast receiver which can be done in the AndroidManifest.xml file so:


        <action android:name=""/>
        <action android:name=""/>
        <action android:name=""/>


You can also register the broadcast receiver from in your Activity or Fragment (for more information about this, see the official Android documentation for BroadcastReceiver). Once the receiver has been registered, broadcasts will be sent to the class:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class MyBroadcastReceiver extends BroadcastReceiver {
    static final class BroadcastTypes {
        static final String SPOTIFY_PACKAGE = "";
        static final String PLAYBACK_STATE_CHANGED = SPOTIFY_PACKAGE + ".playbackstatechanged";
        static final String QUEUE_CHANGED = SPOTIFY_PACKAGE + ".queuechanged";
        static final String METADATA_CHANGED = SPOTIFY_PACKAGE + ".metadatachanged";

    public void onReceive(Context context, Intent intent) {
        // This is sent with all broadcasts, regardless of type. The value is taken from
        // System.currentTimeMillis(), which you can compare to in order to determine how
        // old the event is.
        long timeSentInMs = intent.getLongExtra("timeSent", 0L);

        String action = intent.getAction();

        if (action.equals(BroadcastTypes.METADATA_CHANGED)) {
            String trackId = intent.getStringExtra("id");
            String artistName = intent.getStringExtra("artist");
            String albumName = intent.getStringExtra("album");
            String trackName = intent.getStringExtra("track");
            int trackLengthInSec = intent.getIntExtra("length", 0);
            // Do something with extracted information...
        } else if (action.equals(BroadcastTypes.PLAYBACK_STATE_CHANGED)) {
            boolean playing = intent.getBooleanExtra("playing", false);
            int positionInMs = intent.getIntExtra("playbackPosition", 0);
            // Do something with extracted information
        } else if (action.equals(BroadcastTypes.QUEUE_CHANGED)) {
            // Sent only as a notification, your app may want to respond accordingly.

Sent Event Types

The following type of events are sent with these respective intent extras:

  • A metadata change intent is sent when a new track starts playing. It uses the intent action, and contains the following intent extras:
Intent ExtraTypeDescription
idStringA Spotify URI for the track
artistStringThe track artist
albumStringThe album name
trackStringThe track name
lengthIntegerLength of the track, in seconds
  • A playback state change is sent whenever the user presses play/pause, or when seeking the track position. It uses the intent action and contains the following intent extras:
Intent ExtraTypeDescription
playingBooleanTrue if playing, false if paused
playbackPositionIntegerThe current playback position in milliseconds
  • A queue change is sent whenever the play queue is changed. It uses the intent action and does not contain any additional intent extras.

In addition to the respective intent extras noted above, all broadcasts sent by Spotify contain an additional extra named timeSent (Long), which is the value of system.currentTimeMillis() at the time the broadcast was posted to the system. Since broadcasts can take a bit of time to propagate to your app’s BroadcastReceiver, this can be used to synchronize your app more precisely with the Spotify app. Also it is possible that the last value posted by Spotify is quite old, your app should account for this case if necessary.

Note that in some countries special licenses are required to display synchronized lyrics with music. Please make sure that your application abides by any such legal requirements.

Enabling Media Notifications

The media notifications feature of the Spotify app may disabled by the user for potential privacy concerns. For new or upgrading users of the Spotify app, this feature is disabled unless the user has enabled Facebook scrobbling.

It is not possible for your app to programmatically configure Spotify to enable broadcasting. If your app does not find any broadcast messages, consider showing the user a message asking them to enable this feature by turning Device Broadcast Status to ON in the Spotify app’s settings.