Page 1 of 1
Broadcast Receiver
Posted: 13 Jan 2018 14:30
by bogdyro
Hi. I would like to trigger a flow by sending a broadcast from my android app. I've set the component name of the intent to the Automagic's package name and broadcast receiever class. The action name is something arbitrary like "my.app.send.action". In Automagic i'm setting up a new broadcast trigger and enter the action name. The trigger doesn't fire though.
When looking at the logcat I can actually see a message from AM saying it has caught the broadcast.
D/AM_BroadcastReceiver: received intent Intent { act=my.app.send.action flg=0x10 cmp=ch.gridvision.ppam.androidautomagic/.BroadcastReceiver (has extras) }
So why doesn't the trigger work then ?
Thx. I'm running android 8 on a samsung S8+
Re: Broadcast Receiver
Posted: 13 Jan 2018 16:55
by Desmanto
Try to use action send broadcast from automagic itself. Does it work? If yes, then try using the parameter you want by using putInt() or equivalent, and check if it still works.
Then try to change you app to have no {extras} at all (no parameter). Then try again with parameter. Compare the logcat from automagic and your app. Most likely it is your extras doesn't match the format, then it was discarded after received.
Re: Broadcast Receiver
Posted: 14 Jan 2018 18:38
by bogdyro
I tried sending a broadcast from automagic and the trigger did not fire.
Same message in the logcat though:
D/AM_BroadcastReceiver: received intent Intent...
Does it work for you Desmanto ?
Re: Broadcast Receiver
Posted: 14 Jan 2018 23:52
by Desmanto
Do you have other phone to test it out? Or maybe test it in android emulator?
At mine, it works. I have been using send broadcast and General broadcast for quite a time. But I have changed them to better trigger. Just tested out the old flow, still working, lastest Automagic version at playstore.
I am still using LP 5.1. Probably android oreo required another extra setup to trigger on broadcast. I read this article :
https://medium.com/exploring-android/ex ... 384762a66c
(search "broadcast") But still don't understand what is the real limitation. Do we need to change the app which send the broadcast, or the app which receive it (automagic)?
You should try it on phones before oreo, to see if it works.
Re: Broadcast Receiver
Posted: 15 Jan 2018 07:54
by bogdyro
Well, I had read about new Oreo limitations. The change here is that an app(in this case Automagic) can't register to receive implicit broadcasts in it's manifest file.
So to avoid this I was trying to send explicit broadcasts using the package name and class name of Automagic. This should be allowed in A8.
However I just tried sending an implicit broadcast and it works fine ! The reason for this is that Automagic registers the receiver dinamically (which is logical) and this behavior works in Oreo.
I still don't know why the explicit broadcasts don't work. Waiting on Martin for a response.
But no matter, problem solved
Re: Broadcast Receiver
Posted: 16 Jan 2018 15:44
by Martin
Hi,
Could you please share a flow to illustrate the original problem? Automagic usually requires a trigger to execute a flow and I don't see how you defined the trigger in your first post. Maybe there was some kind of typo in the trigger General Broadcast or something similar. An example flow would greatly help to reproduce the issue. You can also turn on Debug log in the settings of Automagic to see if there's an error in the log of Automagic.
Regards,
Martin
Re: Broadcast Receiver
Posted: 16 Jan 2018 20:46
by bogdyro
It's the way I send the broadcast. it works if I don't use explicit broadcast.
http://automagic4android.com/flow.php?i ... aa088f20fc
Re: Broadcast Receiver
Posted: 18 Jan 2018 17:58
by Martin
The broadcast receiver you defined in the action Send Broadcast is a broadcast receiver that only handles a few specific intents so the filter does not match.
You can send an explicit broadcast to Automagic by leaving the class name field empty but still filling out the package name field. This ensures that the broadcast is just sent to Automagic but not to any other apps.
Regards,
Martin
Re: Broadcast Receiver
Posted: 18 Jan 2018 19:36
by bogdyro
Great, thx!