Bluetooth control - single button?

Post your questions and help other users.

Moderators: MURTUMA, Martin

Posts: 102
Joined: 12 Aug 2013 16:28

Bluetooth control - single button?

Postby evebrea » 01 Jan 2019 23:01

I got a Chinese Bluetooth earbud to listen to music at work and being a single earbud it only has one button. The button on single press seems to trigger play/pause Android intent for whatever your main music player is (it's triggering my app "music player" not Google music) and on hold it tries to dial the phone.

Is there any way I could make automagic recognize what the earbud is sending and make it into music controls? Like long press triggers one flow, and multiple presses triggers a flow for "next song"

User avatar
Posts: 1400
Joined: 21 Jul 2017 18:50

Re: Bluetooth control - single button?

Postby Desmanto » 03 Jan 2019 18:36

Use Trigger Hardware Key Event, filter for the play pause. Or if you don't know the exact key, try to check all and put debug dialog. Press the key and check the key name in the debug dialog. Use that.

I have created the flow to proof the concept : viewtopic.php?f=3&t=7830
Replace the key detected to the trigger.

Usually the single press will send certain key (play/pause), while long press will send another key (stop). We can actually combine them, but very difficult to do with very short timeout. I suggest just use only one of them at one flow, not the combination.
Index of Automagic useful thread List of my other useful posts (and others')

Posts: 102
Joined: 12 Aug 2013 16:28

Re: Bluetooth control - single button?

Postby evebrea » 07 Jan 2019 22:46

Instead I went with hardware key and used the volume up and volume down from the phone for next/previous song on double tap.. but it doesn't seem to pick up hardware key if the screen is off.

i went with this because the earbud was putting out media_pause, media_play, and nothing for the double-tap call (so i turned off it's call abilities in the bluetooth menu)
and just the same it wasn't listening to them with the screen of. despite that the music did pause, automagic had no idea

User avatar
Posts: 1400
Joined: 21 Jul 2017 18:50

Re: Bluetooth control - single button?

Postby Desmanto » 09 Jan 2019 18:44

Unfortunately, accessibility only works when the screen is on. This is known limitation from android itself. So during screen off, the key is not blocked, as Automagic is not intercepting it anymore.

If you don't mind the battery, you just have to make sure the screen is on during the control. You can use a flow to turn the brightness close to the minimum, not 0 (some phones show 0 as backlight off, total darkness) and set the display timeout to never. You can protect the screen from getting mistouch, by overlaying a full screen transparent widget with action, to block the accidental touch. Use another flow to toggle these all back to normal. (auto brightness, timeout to normal, and hide the widget).
Index of Automagic useful thread List of my other useful posts (and others')

Return to User Help / Bug Reports

Who is online

Users browsing this forum: No registered users and 10 guests