3

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

  • @beeshyams yes it is, but the solution should also cover unrooted devices, as this is not only a concern to me. – Peter Jul 12 '17 at 12:12
  • @beeshyams How would a tasker solution look like? You can add it as an answer here for rooted devices and if someone would come up with a non-root solution, he could edit your answer. – Peter Jul 12 '17 at 12:21
  • It's not mine. I don't know Tasker so will not post that solution. But [here it is]( xda-developers.com/…) – beeshyams Jul 12 '17 at 12:28
  • My solution is using Macrodroid which is another automation app. You can test it and let me know if it works- I can't test since I don't use Spotify. Trigger: Bluetooth Event > device connected > any device Action: Kill app > Spotify (requires root ). You can test this in 5 minutes – beeshyams Jul 12 '17 at 12:34
  • @beeshyams I like the link you posted! AFAICT it doesnt need root (since you can do adb commands via usb debugging) only need to enable Tasker accessibility service, good research though! – xavier_fakerat Jul 12 '17 at 15:07
3

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

enter image description here enter image description here enter image description here

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

  1. Enabled Bluetooth audio service (to use PC speakers to listen to remote audio).

  2. Open two different music apps on android and played music and play

  3. Created a “media button grab” in Tasker to handle Media Button key events.

  4. Retested (2) with Tasker running the previously created task.

enter image description here

Results

  1. On test (2) the audio output was transferred to PC speakers indicating that the autoplay feature was still active.

  2. 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 & Play

enter image description here enter image description here enter image description here

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

Acknowledgements

-1

If you are been annoyed by your smart android phone auto starting the music when you start your car. Here is the solution I found snooping around: Open up your Google Chrome browser on he phone, click on the right upper corner bottom, click on settings, advance, site settings, media and turn off auto play. Bingo. Now you can play any media when you want. JT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.