【发布时间】:2011-05-16 21:58:49
【问题描述】:
我正在创建一个触发 Intent 的通知。这是我的代码的一个非常简短的摘录......
Notification notification = new Notification(R.drawable.icon, "notification", System.currentTimeMillis());
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(BackgroundService.this, ConnectionHandler.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, getString(R.string.notification_title), getString(R.string.notification_body), pendingIntent);
notification.flags |= notification.FLAG_AUTO_CANCEL;
nm.notify(1, notification);
在我的意图 (ConnectionHandler.class) 中,我想展示一个有效的 AlertDialog。但我希望在不打开新 UI 窗口的情况下显示 AlertDialog。对我来说最好的是,如果在点击通知条目时 AlertDialog 只是简单地出现而没有任何其他内容。
任何想法都值得赞赏。
问候,托比
【问题讨论】:
-
谢谢@henrik。来晚了,还没看。
标签: android user-interface notifications android-intent