Prevent music players from auto play on bluetooth connect Whenever I connect my android device with a bluetooth device, it automatically starts spotify and starts playing.
As far as I know this also happens to other users/players (according to google)

How can I prevent this (without signing out of spotify)?

Android: 6.0.1
Spotify Version: 6.2.0.1015
Background

Major part of this guide was extracted here: How to Disable Bluetooth Automatic Playback on any Android Phone

The point of this guide isn't to disable Bluetooth music entirely, otherwise the latter can easily be achieved by:

Disable Bluetooth Music : Settings >> Bluetooth >> Your device(Car) >> Settings  then uncheck audio support.

..and this simply destroys the whole purpose of the guide.

 It is important to know that autoplay is a feature of many Bluetooth devices, despite the fact people do see this "feature" as a problem though, which is the original reason the original author wrote the guide.



Understanding Bluetooth Autoplay on Android


What essentially happens when you connect a Bluetooth device that sends an autoplay command is that this command is seen as a KeyEvent for toggle play/pause in Android. 
Applications with a MediaButtonReceiver broadcast receiver can then react to this Media Button event.
Android keeps track of the last application that requests to receive Media Button events.



  Any new media application can take over to listen to Media Button key
  events by calling setMediaButtonReceiver in AudioManager, and that
  application will handle Media Button key events until another
  application requests control.


You can actually see which application is currently set to respond to these key events by entering the following ADB command:

adb shell settings get secure media_button_receiver

On the author’s device, this command yielded the following output:

com.google.android.music/com.google.android.music.playback.MediaButtonIntentReceiver


  This is the broadcast receiver set up by Google Play Music to respond
  to Media Button key events. So if I plug in my Bluetooth device, my
  phone will automatically start playback in Google Play Music.


Disabling Bluetooth Autoplay with Tasker

Profile (or Trigger)


Goto Profiles Tab and click the "+"
Event >> State >> Net >> BT Connected
Tap back to exit from this window


Task

You will notice as soon as you exit, you will be prompted to link this to a Task


Scroll all the way up the Task list select "New Task + "
You can just keep it anonymous or give it a name
Click "+" to add new Action
Media >> Media Button Events >> Grab
Tap back to exit from this task


AFAIK root is not necessary for this task

  

Once you’re done, Tasker should now automatically set itself as the Media Button Receiver in Android upon connection to your selected Bluetooth devices. This way, the play/pause action that is sent will not be received by any of your media applications, but instead by Tasker

Unfortunately I couldn’t get Spotify or Soundcloud music application to replicate the issue. However, I retested this feature using a PC with the remote audio service (Bluetooth module on my PC supports that) to test the bluetooth autoplay feature.

Tests done 


Enabled Bluetooth audio service (to use PC speakers to listen to remote audio).
Open two different music apps on android and played music and play
Created a “media button grab” in Tasker to handle Media Button key events.
Retested (2) with Tasker running the previously created task.




Results


On test (2) the audio output was transferred to PC speakers indicating that the autoplay feature was still active.
After performing test (4), the audio sound output came from android and was not transferred to PC speakers. Which essentially solves the issue.




Alternatively..

Head to playstore and get Bluetooth connect &amp; Play

  

You can tell it which app should play for each bluetooth device (or to NOT play on a given BT device)

Acknowledgements


Original author: Mishaal Rahman
Beeshyams