Broadcast Receiver

Post your questions and help other users.

Moderator: Martin

Post Reply
bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Broadcast Receiver

Post by bogdyro » 13 Jan 2018 14:30

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+

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Broadcast Receiver

Post by Desmanto » 13 Jan 2018 16:55

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Broadcast Receiver

Post by bogdyro » 14 Jan 2018 18:38

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 ?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Broadcast Receiver

Post by Desmanto » 14 Jan 2018 23:52

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Broadcast Receiver

Post by bogdyro » 15 Jan 2018 07:54

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

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

Re: Broadcast Receiver

Post by Martin » 16 Jan 2018 15:44

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

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Broadcast Receiver

Post by bogdyro » 16 Jan 2018 20:46

It's the way I send the broadcast. it works if I don't use explicit broadcast.
http://automagic4android.com/flow.php?i ... aa088f20fc

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

Re: Broadcast Receiver

Post by Martin » 18 Jan 2018 17:58

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

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Broadcast Receiver

Post by bogdyro » 18 Jan 2018 19:36

Great, thx!

Post Reply