hi, I ve searched for answer here but nothing seems to work as
expected.

I have a service that in onStartCommand sends notification, created as

final Notification notification = new Notification(icon, notify_title,
when);
final Intent notificationIntent = new Intent(this, MyActivity.class);
final PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
notification.setLatestEventInfo(this, notify_title, expandText,
contentIntent);
notification.flags = Notification.FLAG_ONGOING_EVENT |
Notification.FLAG_NO_CLEAR | Notification.FLAG_FOREGROUND_SERVICE;
mNotificationManager.notify(SERVICE_STARTED_NOTIFICATION_ID,
notification);

and this is fine but in onDestroy I try to clear that notification, I
thought that
mNotificationManager.clear(SERVICE_STARTED_NOTIFICATION_ID) would be
enough but it wasnt.

then I tried to post another notification and then clear it like

final Notification notification = new Notification(icon, notify_title,
when);
final PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(this, stopping_title, stopping_text,
contentIntent);
//        notification.flags = Notification.FLAG_ONLY_ALERT_ONCE |
Notification.FLAG_AUTO_CANCEL;

mNotificationManager.notify(SERVICE_STARTED_NOTIFICATION_ID,
notification);
//       mNotificationManager.cancelAll();

I tried with and without flags (Notification.FLAG_ONLY_ALERT_ONCE |
Notification.FLAG_AUTO_CANCEL),
with and without mNotificationManager.cancelAll() or
cancel(SERVICE_STARTED_NOTIFICATION_ID)
clicking on notification itself is not clearing it.

the service and other activities are not running (I dont see them in
process manager) Im really out of ideas!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to