【发布时间】:2010-08-05 18:54:40
【问题描述】:
1/如果这个应用程序已经在前台运行我的应用程序,我不想通知用户,
在创建通知之前是否可以检查我的应用程序是否不在前面?
2/如果应用在后台,是否可以将最后一个状态放在前面?
我知道Os可以销毁一些Activity,但是是否可以恢复上一个状态,不要启动一个新的Intent?
因为如果我开始一个新的 Intent 并且我推回,旧的 Intent 看起来有 2 个相同的 Intent 启动不是很漂亮。
谢谢
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Intent notificationIntent = new Intent(this, z_finish.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Notification notification = new Notification(icon, tickerText, when);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);
【问题讨论】:
-
对,但你没有接受这篇文章的任何答案,请注意我的通知是在后台的服务中完成的,而你的?
标签: android service background notifications android-service