0

我试过通知样本。

我可以在通知点击事件上打开活动。

是否可以在通知点击事件上打开所需的选项卡小部件。

任何任何机构都可以帮助我在通知点击事件上打开标签主机。

请检查下面的代码..

    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);
4

1 回答 1

1

假设您使用的是 TabHost——如果您需要以编程方式设置当前选项卡,您可以使用TabHost#setCurrentTab(int)TabHost#setCurrentTabByTag(String)

于 2013-11-12T04:19:38.667 回答