Do you mean to play Spotify music in your app? This is usually not possible, because music requires authorization, but if you have an audio file, you can put it in the cloud and use the following code to play it.
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(applicationContext, Uri.parse("music url"))
mediaPlayer.setOnPreparedListener { it.start() }
mediaPlayer.prepareAsync()
Alternative plan
The Spotify SDK allows your application to interact with the Spotify app running in the background as a service. The capabilities of this API include getting metadata for the currently playing track and context, issuing basic playback commands and initiating playback of tracks.
Please refer to: https://developer.spotify.com/documentation/android/