Page 1 of 1

Detect notification tray

Posted: 10 Oct 2016 11:40
by MURTUMA
Is it possible to detect when opening notification tray?

Triggers App task started/ended react when opening and closing notif.tray if set to current foreground app, but I have yet to find a way to detect the tray itself.

Triggers Activity started/ended won't have any reaction.

Re: Detect notification tray

Posted: 10 Oct 2016 19:02
by Martin
You could try trigger UI Event with event Window opened, package com.android.systemui and contains text Notification shade.
The trigger might need different settings on your device so you might have to leave contains text empty and use an action Write to Log {text} to see if the text is a different one on your device. I've just tested on a Nexus 5X with Android 7 so it might not work at all on different versions of Android or other ROMs.

Re: Detect notification tray

Posted: 10 Oct 2016 21:57
by MURTUMA
Thank you, it works.

That trigger didn't occur to me because on my previous phone(KK) the notification tray didn't "interfere" with App Task triggers. Things has changed on Marshmellow.

Re: Detect notification tray

Posted: 11 Oct 2016 10:21
by MURTUMA
One more question. Is it possible to detect this with a condition? With the trigger I can't make reliable solution for the interfering I mentioned because most of the time App task ended fires before Ui event.

Or I could use trigger Activity started:*/*, excluding only the desired app but that would be triggering all the time I do something with my phone. Thus I'd prefer trigger App task ended.

Re: Detect notification tray

Posted: 12 Oct 2016 19:00
by Martin
A condition is tricky. A condition App Task Running: com.android.systemui could work but also includes other things like recent tasks and probably a few other screens.
Maybe you could add a short delay (e.g. 100ms) to the flow that is triggered by App task ended to ensure that the UI event is handled first.

Re: Detect notification tray

Posted: 13 Oct 2016 11:21
by MURTUMA
This solution seems to work quite reliably. Indeed it needs a short sleep action or the condition does not catch the system ui task.