Thanks! Yes, in your automation app you'll need to use the Plugin event, or if it supports condition/state contexts, you can use those too.
AppContext does not run in the background like a Service. It is a BroadcastReceiver, which is indeed called when needed and communicates to the automation API. After that it is either killed or cached, that's up to the Android system.
Regarding your suggestion: I'm actually investigating if I can implement that.
Thanks for the explanation!
I use mostly triggers regarding app Activities so it would be very useful if you could add this kind of discrimination.
I give you some info about Automagic behaviour on this. Automagic uses two types of detection you can choose for activity recognition: "classic" which uses the accessibility service and "usage statistics" which is more experimental and works on Lollipop+ (the description says that).