Android 在通知时调用tabhost单击

Android 在通知时调用tabhost单击,android,android-intent,Android,Android Intent,我试过通知样品 我可以在通知单击事件时打开活动 是否可以在通知单击事件时打开所需的选项卡小部件 任何正文都可以帮助我打开“主机通知”选项卡单击事件 请检查下面的代码 int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) cont

我试过通知样品

我可以在通知单击事件时打开活动

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

任何正文都可以帮助我打开“主机通知”选项卡单击事件

请检查下面的代码

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

假设您使用的是TabHost--如果您需要以编程方式设置当前选项卡,您可以使用或

David,我可以这样做..但我希望它只在单击通知时发生。。可能吗?提前谢谢:我明白了。我自己还没有做过,但我想你需要注册一个来监听通知点击事件。