Android : Filter broadcasts based on sending class

on Sunday, October 12, 2014


I have a custom Service ParentService which listens to a Bluetooth sensor. However, I need two of these in my application so I subclass it to create ChildService1 and ChildService2 and these sample data and send local broadcasts which are defined public static final String in the parent class. The problem is that the two broadcast receivers in my Activity both receive actions from ChildService1 and ChildService2. Is there a way to customize my IntentFilter to only receive an action that was sent by ChildService1?


The other option is to defien the Action strings as just public String and the child classes specify their own custom Actions which the parent class will send. Is this a bad solution?


0 comments:

Post a Comment