Detect notification tray

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Detect notification tray

Post by MURTUMA » 10 Oct 2016 11:40

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.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Detect notification tray

Post by Martin » 10 Oct 2016 19:02

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.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Detect notification tray

Post by MURTUMA » 10 Oct 2016 21:57

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.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Detect notification tray

Post by MURTUMA » 11 Oct 2016 10:21

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.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Detect notification tray

Post by Martin » 12 Oct 2016 19:00

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.

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: Detect notification tray

Post by MURTUMA » 13 Oct 2016 11:21

This solution seems to work quite reliably. Indeed it needs a short sleep action or the condition does not catch the system ui task.

Post Reply