【问题标题】:calling tabhost on notification click在通知点击时调用 tabhost
【发布时间】:2013-11-12 04:08:56
【问题描述】:

我已经尝试过通知示例。

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

是否可以在通知点击事件中打开所需的标签小部件。

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

请检查下面的代码..

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

【问题讨论】:

    标签: android android-intent


    【解决方案1】:

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

    【讨论】:

    • 大卫我可以做到......但我希望它只有在我们点击通知时才会发生......这可能吗?在此先感谢:D
    • 我明白了。我自己还没有完成,但我想你需要注册一个BroadcastReciever 来监听通知点击事件。 Something similar to this
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多