【发布时间】:2011-07-04 10:08:27
【问题描述】:
我有一个在服务的帮助下播放媒体的应用程序。这在服务的帮助下运行顺利(创建了持续的通知)。当按下返回键时,应用程序进入后台。问题是当我单击通知图标时,每次都会创建我的应用程序的新实例。如何借助通知栏让我的应用从后台转到前台?
我的通知如下所示:
private void notifyMe() {
final NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.icon_audio, "Online!",
System.currentTimeMillis());
note.flags = Notification.FLAG_ONGOING_EVENT;
PendingIntent i = PendingIntent.getActivity(this, 0, new Intent(this, PlayMedia.class), 0);
note.setLatestEventInfo(this, "Media Payer", "Online",i);
mgr.notify(NOTIFY_ME_ID, note);
}
解决方案 我通过在清单文件中添加以下行来让它工作:android:launchMode="singleInstance" 意图标志没有任何效果,认为这很奇怪......
【问题讨论】:
标签: android