So I wanted to integrate the spotify library into an android app. I went to https://developer.spotify.com/technologies/libspotify/ and downloaded their lib libspotify-12.1.5
Spotify have published a SDK BETA version for android.
https://github.com/spotify/android-sdk
They have a few examples of initializing a player and playing a track using TRACK_CHANGE event (Only available from Beta10). Here is one that doesn't use TRACK_CHANGE:
mPlayer = Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
@Override
public void onInitialized(Player player) {
mPlayer.addConnectionStateCallback(MainActivity.this);
mPlayer.addPlayerNotificationCallback(MainActivity.this);
mPlayer.play("spotify:track:2TpxZ7JUBn3uw46aR7qd6V");
}
@Override
public void onError(Throwable throwable) {
Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage());
}
});
(Took the code from the tutorial - https://developer.spotify.com/technologies/spotify-android-sdk/tutorial/)