Nemanja Kovacevic
Nemanja Kovacevic

Reputation: 3560

How to pass intent from TabActivity to its child activity

I need some help :)

I have a tab activity with four sub activities. First and most important is a list activity, second also list, third is settings activity and fourth with help.

When app is launched tab activity creates specs with intents for sub activities and sets first activity as a current tab so that activity acts upon intent from spec and that works fine. Later a broadcast receiver can broadcast notification with intent to refresh first list activity because new data has arrived.

My goal is: When the user acts upon notification: If app is launched, so there is a task on stack but not on top, to refresh that existing list activity inside tab and bring the whole app to front. If app is already visible but on different sub activity (different tab) just to navigate to first tab and refresh first list. If first list (first tab) is already visible just to update it.

I can't seem to make this work. I've tried different strategies. Intent that targets tab activity. Intent that target sub activity. Combinations of launchMode and intent flags but i cannot make this work. It seems to me as a reasonable scenario.

Any insight will be appreciated.

Upvotes: 4

Views: 743

Answers (1)

Nemanja Kovacevic
Nemanja Kovacevic

Reputation: 3560

OK this workaround worked for me:

TabActivity has an onNewIntent(...) method which handles intents that I want to pass to child activity. TabActivity will call a method on custom application object. That object will pass message to ChildActivity which passed it self as a listener on app object on creation.

Upvotes: 1

Related Questions