开发者

Will an IntentFilter work for this?

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, kn开发者_StackOverflow中文版ows 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?


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 ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜