Bluetooth control - single button?

Post your questions and help other users.

Moderator: Martin

Post Reply
evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Bluetooth control - single button?

Post by evebrea » 01 Jan 2019 22: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
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Bluetooth control - single button?

Post by Desmanto » 03 Jan 2019 17: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')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Re: Bluetooth control - single button?

Post by evebrea » 07 Jan 2019 21: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
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Bluetooth control - single button?

Post by Desmanto » 09 Jan 2019 17: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')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply