Question

I have a situation in which the same activity class is being created by the creation of tabs in a tabhost control. Subsequently, each instance of the activity will want to inform a select group of its peers of some user action. Conversely, each activity, when it's constructed/created, knows which activity[only one] to accept broadcast messages from.

My thought is to define programmatically an IntentFilter for each registered receiver which would hold the identifying string of the broadcaster it wishes to hear from.

Will this work and, if so, how would I define the IntentFilter in code?

Was it helpful?

Solution

Yes, it does work... beautifully!

I passed the identifying string from the creating activity to the offspring as an 'extra' member of the creating intent. This string was then defined as the IntentFilter category[iFilter.addCategory(identStr)].

Broadcast intents are then assigned the same category[iMsg.addCategory(identStr)] and are then received by the specific activities which had registered a receiver with the matching identifying string as the filter category.

Very powerful ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top