0

i have tried notification sample.

i can able to open activity on notification click event.

is it possible to open the desired tab widget on notification click event.

any any body help me to open the tab host on notification click event.

please check the below code..

    int icon = R.drawable.ic_launcher;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager)
            context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    Intent notificationIntent = new Intent(context, Viewmessage.class);
    notificationIntent.putExtra("NotificationMessage",message);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingNotificationIntent = PendingIntent.getActivity(context,0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.setLatestEventInfo(context, title, message, pendingNotificationIntent);
    notificationManager.notify(0, notification);
user2330792
  • 67
  • 1
  • 9

1 Answers1

1

Assuming you're using a TabHost -- If you need to set the current tab programmatically you can use TabHost#setCurrentTab(int) or TabHost#setCurrentTabByTag(String)

dm78
  • 1,570
  • 1
  • 16
  • 28
  • David i can do it ..but i want it to happen only when we click the notification.. is it possible? thanks in advance :D – user2330792 Nov 12 '13 at 04:23
  • I see. I haven't yet done it myself, but I imagine you'll need to register a [BroadcastReciever](http://developer.android.com/reference/android/content/BroadcastReceiver.html) to listen for the notification click event. [Something similar to this](http://stackoverflow.com/a/15521314/1830141) – dm78 Nov 12 '13 at 04:33