我正在创建一个触发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只显示其他任何内容。
任何想法都表示赞赏。
此致,托比