1

I'm writing a custom upload notification, very similar to that from the Picasa Photo Uploader http://code.google.com/p/picasaphotouploader/source/browse/trunk/src/com/android/picasaphotouploader/UploadNotification.java

At creation, I set the FLAG_ONGOING_EVENT and it works. After the upload is done, i have these two lines:

flags =~ Notification.FLAG_ONGOING_EVENT; flags += Notification.FLAG_AUTO_CANCEL;

However, my notification is not cancelable, and flags has a value of -3. Do you have any idea why I can't change the flags anymore?

dulys
  • 77
  • 1
  • 9
  • Did you update the `Notification` via `notify()` after changing the flags? – CommonsWare Sep 30 '11 at 14:39
  • Yes I did `manager.notify(id, this);` Anyway, I ended up manually setting the value of flags to 16 for FLAG_AUTO_CANCEL, but I would still like to know what exactly is happening... – dulys Oct 04 '11 at 09:20

1 Answers1

4

A late answer but just in case someone else runs into this issue. I believe you should be using bitwise operations instead of arithmatic operations here.

In this case use:

flags = (~Notificatoin.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL);

This may look weird because, if you don't know bitwise operations, your instincts tell you "not ongoing or auto cancel" but it really means to disable the ongoing bit and to enable the auto cancel bit.

I suggest reading up on bitwise operators and bit masks.