samedi 9 avril 2016

Should BroadcastReceiver be declared inside activities?

I'm wondering what's the better cleaner design approach to handle BroadcastReceiver creation between those two:

  1. Declaring directly a BroadcastReceiver in an Activity/Fragment and overriding onReceived method there.

  2. Creating another custom receiver class in a package "receiver", that extends the BroadcastReceiver class and override onReceive. Then, you instantiate that custom receiver class in your Activity/Fragment.

Aucun commentaire:

Enregistrer un commentaire