0

I have implemented Tab host with the Notification. Now My problem is: there are 3 tabs like Food, Health and Service. If i receive a Food Notification How to highlight the Food Tab automatically

Pankaj
  • 7,908
  • 6
  • 42
  • 65
ravi chandra
  • 60
  • 1
  • 9

2 Answers2

0

For switching to some other tab than the default one you need to put this code on the onClick or whatever triggers the action

TabActivity tabs = (TabActivity) getParent(); tabs.getTabHost().setCurrentTab(x);

Just replace x with the tab which you would like to navigate to and make sure to change the variable names and class names as per your project. Hope it helps you ;)

0

Do like this :

First Step: Create a broadcast receiver which you can call when you click on notification

Intent notificationIntent = new Intent(context,
                PushNotificationBroadcastReceiver.class); // this is the broadcast receiver which will be called 
                PendingIntent resultPendingIntent = PendingIntent.getBroadcast(context,
                1, notificationIntent, 0);

Second Step: in onReceive() method put below line:

TabActivity tabs = (TabActivity) getParent();
    tabs.getTabHost().setCurrentTab(2);  //2 means the position of tab which you want to show

That's it.

Pankaj
  • 7,908
  • 6
  • 42
  • 65