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?

4

1 に答える 1

4

遅い答えですが、他の誰かがこの問題に遭遇した場合に備えて。ここでは、算術演算の代わりにビット単位の演算を使用する必要があると思います。

この場合、次を使用します。

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

これは奇妙に見えるかもしれません。なぜなら、ビット単位の操作を知らない場合、本能的に「進行中ではないか自動キャンセル」と判断するからです。実際には、進行中のビットを無効にして自動キャンセル ビットを有効にすることを意味します。

ビット単位の演算子とビット マスクを読むことをお勧めします。

于 2012-12-17T21:49:22.230 に答える