Page 1 of 2

Media buttons recognize only on screen on

Posted: 07 Dec 2019 12:07
by Sergey_777-s
using hardware key event I try to execute flow when MEDIA_PREVIOUS on my Bluetooth device pressed. When screen is on all works correctly! But on turn off screen automagic not recognize MEDIA_PREVIOUS button pressing on hardware phone keys all OK, problem only with the MEDIA_* keys on blank screen. How to fix this problem?

Re: Media buttons recognize only on screen on

Posted: 07 Dec 2019 17:17
by Desmanto
Hardware key event trigger works using accessibility services, which get suspended when the screen is off. So none of the hardware key event flow can be triggered when screen off. For the media button, you can try trigger Media Button Event (Experimental) instead. It also has all the media button there and should work in screen off.

However other media app can steal the media button focus. So if you use the buttons in call/music/video player, from time to time, you might need to use action Reregister Media Button Receiver to make Autoamgic can react to the media button again. Or simply use action sound - silent, so Automagic gain the audio focus and media button again.

Re: Media buttons recognize only on screen on

Posted: 07 Dec 2019 22:03
by Sergey_777-s
I re-register button service but nothing works on screen off

Re: Media buttons recognize only on screen on

Posted: 08 Dec 2019 16:33
by Desmanto
I have tried with my bluetooth headset, pressing media play/pause, next and prev, works at mine at screen off. Do you have any kind app of that can steal the media button focus at screen off? Try first at the flow and setup a very simple flow. Use trigger Media button event : all button, and vibrate. At screen on, try and see if it works. Then turn screen off, immediately test again.

If at screen on, it doesn't react, you can try to play a silent sound first at automagic. This just to ensure Automagic has the media button focus.

Re: Media buttons recognize only on screen on

Posted: 10 Dec 2019 22:35
by Sergey_777-s
I tryed this, when, for example I get event play/pause on my Bluetooth device I setup automatic to vibrate, when screen on - my phone vibrate when I press play button. But when I press play button on off screen the phone doesn't vibrate and starts aimp player an I listen the music but must be vibration

Re: Media buttons recognize only on screen on

Posted: 11 Dec 2019 16:42
by Desmanto
It seems the aimp got the focus as soon as the screen off. Do you test this when the music is playing? Can you try to exit AIMP and then force stop it first to try again? Or maybe even further, uninstalling (if you don't have any setting/playlist need to be saved).

I try this with minilyric open, not playing sound. Screen off, bluetooth media button still works. Once I tap play at minilyric, all focus now changed to minilyric, screen on and off. I play notif sound at Automagic and now shifted back to Automagic.

Re: Media buttons recognize only on screen on

Posted: 12 Dec 2019 20:05
by Sergey_777-s
No aimp isn't a problem, when I kill aimp and press forward button on bluetooth when music isn't playing automagic react only when screen is on, on off screen nothing happens

Re: Media buttons recognize only on screen on

Posted: 13 Dec 2019 18:51
by Desmanto
What is your current phone and android version? It seems something is limiting the screen off capability of Automagic. Try to grant Automagic device administrator permission. It seems you also need to enable debug log in Automagic and check it later to see if there is any event when screen off. You might want to try to your other device if you have secondary/older device with different android version.

Re: Media buttons recognize only on screen on

Posted: 15 Dec 2019 23:37
by Sergey_777-s
It's 7 version of Android with all permissions and no events in the debug log with screen off

Re: Media buttons recognize only on screen on

Posted: 16 Dec 2019 17:43
by Desmanto
I assume you have whitelisted Automagic from the battery optimization. But some brand have another killer app in the background which stop all background activity after the screen is off. See : https://dontkillmyapp.com/ and find the instruction for your device brand.

You need to try on other device to see if that is the case. It is working at mine, I don't use any task killer and have whitelisted automagic from any kind of battery optimization or possible limiter.