You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Add @Receiver to inject the annotated receiver #852
The second proposal of the issue #484 seems interesting to me and looks like this proposal.
The main issue is to decide when the BroadcastReceiver should be registered and unregistered (onResume/onPause or onStart/onStop or onCreate/onDestroy).
I propose an annotation @Receiver with two parameters :
actions which is an array of String indicating the action to add to the IntentFilter
registerAt (or another name) which is an enum indicating when the BroadcastReceivershould be registered and unregistered (onResume/onPause or onStart/onStop or onCreate/onDestroy).
So with this annotation the receiver will be injected in the field and automatically registered to the context according to the chosen scope (ie registerAt).
Seems interesting. I'm planning this for 3.1
I think the doc is incorrect. @Receiver is intended to be used on methods, not fields. However we should really provide a way to inject enhanced BroadcastReceivers.
Activity
DayS commentedon Jan 2, 2014
Why not. And it doesn't cost much :)
yDelouis commentedon Jan 2, 2014
The second proposal of the issue #484 seems interesting to me and looks like this proposal.
The main issue is to decide when the
BroadcastReceivershould be registered and unregistered (onResume/onPauseoronStart/onStoporonCreate/onDestroy).I propose an annotation
@Receiverwith two parameters :actionswhich is an array ofStringindicating the action to add to theIntentFilterregisterAt(or another name) which is an enum indicating when theBroadcastReceivershould be registered and unregistered (onResume/onPauseoronStart/onStoporonCreate/onDestroy).PerfectCarl commentedon Jan 3, 2014
@yDelouis :+1
But then it is slightly more then.... :)
The added benefit of this annotation would be to keep the AndroidManifest leaner for BroadcastReceiver that leaves only in one Activity's context.
DayS commentedon Jan 3, 2014
So with this annotation the receiver will be injected in the field and automatically registered to the context according to the chosen scope (ie registerAt).
Seems interesting. I'm planning this for 3.1
WonderCsabo commentedon Jan 12, 2014
I think we should handle
LocalBroadcastManagersomehow. For example we could add alocalmethod to@Receiver, which isfalseby default.yDelouis commentedon Jan 13, 2014
I added the
localparameter into my PR.WonderCsabo commentedon Jan 13, 2014
Great! Thank you very much. I hope it will be merged soon.
DayS commentedon Mar 16, 2014
Merged :)
PerfectCarl commentedon May 28, 2014
Here's the updated documentation for it:
https://github.com/PerfectCarl/androidannotations/wiki/Enhance-broadcastreceivers
https://github.com/PerfectCarl/androidannotations/wiki/AvailableAnnotations
WonderCsabo commentedon May 28, 2014
I think the doc is incorrect.
@Receiveris intended to be used on methods, not fields. However we should really provide a way to inject enhancedBroadcastReceivers.PerfectCarl commentedon May 28, 2014
Oops, indeed. The final implementation is very different from my initial proposal.
Okay, I need to do some more research about this :)
PerfectCarl commentedon May 29, 2014
Okay, I played with the feature (which I should have done in the first place) and fixed the documentation
https://github.com/PerfectCarl/androidannotations/wiki/Enhance-broadcastreceivers
https://github.com/PerfectCarl/androidannotations/wiki/AvailableAnnotations
https://github.com/PerfectCarl/androidannotations/wiki/Receiving-intents
https://github.com/PerfectCarl/androidannotations/wiki/Enhance-Fragments
https://github.com/PerfectCarl/androidannotations/wiki/Enhance-services
WonderCsabo commentedon May 31, 2014
I read the updated doc, very nice work!
PerfectCarl commentedon May 31, 2014
Added IntentService #1019 :)